Introduction
A backup is a duplicate or a copy on a different storage medium. File synchronization is the process of ensuring that two or more locations contain the same, up to date, files, i.e., the same data is updated across multiple locations and platforms.
A backup strategy is a plan made to ensure that essential data is backed up and ready to restore if there is any kind of disaster and data loss. It is highly necessary but it is often neglected.
- File-sharing services are the easiest ways to back up and sync files and directories among computers. They usually include file sharing, synchronization across multiple devices, and collaboration features.
Dropbox “is a free service that lets you bring all your photos, docs, and videos anywhere. After you install Dropbox on your computer, any file you save to your Dropbox will automatically save to all your computers, your Android device, and even the Dropbox website! With the Dropbox app, you can take everything that matters to you on the go.” Other alternatives are Google Drive, pCloud, and OneDrive.
- Let’s install Dropbox in Arch.
git clone https://aur.archlinux.org/dropbox.git # Firstly, we clone its repository
cd dropbox
makepkg -si # Create a package, install the package and missing dependencies after a successful build.
Finally, we want the service to autostart on boot with systemd: sudo systemctl edit dropbox@user (e.g., dropbox@nmaximo7):
[Service] Environment=DISPLAY=:0
Some backup solutions you may consider are:
- Clonezilla is a partition and disk imaging/cloning program. It is a free alternative to Norton Ghost.
- Paragon Backup & Recovery is one of the best, free backup solutions.
- Déjà Dup Backup Tool is a very simple and yet powerful GUI tool for backup in Ubuntu.
- Timeshift is an open-source backup and restore application for Linux similar to the Time Machine tool in Mac OS. It protects your system by taking incremental snapshots of the file system at regular intervals.
- rsync is a free, fast, and extraordinary versatile utility for transferring files and synchronizing local and remote directories.
- AOEMI Backupper is a free and easy data backup, disk clone and file sync software for personal PCs and iOS devices.
- Macrium Reflect Free Edition is a free backup, free cloning, and free disk imaging software.
Syncthing
Syncthing is a continuous file synchronization program. It is a really good free alternative to Dropbox and Google Drive. It synchronizes files between two or more computers.
- Let’s install it on Ubuntu: sudo apt install syncthing-gtk (the GTK3-based GUI for syncthing, it will also install the package syncthing). Arch: sudo pacman -S syncthing.
- Next let’s edit its config file (vi /home/user/.config/syncthing/config.xml) and change 127.0.0.1:8384 (only listening to localhost) to 0.0.0.0:8384.
- If you are in Ubuntu, the installation is made so that the service is run as root. You may want to check its status: sudo systemctl status syncthing@root.service However, you need to enable and start the system service (syncthing@yourUser.service) in Arch:
systemctl enable syncthing@yourUser.service
systemctl start syncthing@nmaximo7.service
- Install Mac (client). We should be able to access it: IP’s address:8384.
- For security purposes you may want to change your password: Actions, Settings, GUI Authentication User, GUI Autentication Password.
- Syncthing uses port 22000. If your computer has enabled the UFW firewall, then you need to allow traffic on port 22000: sudo ufw allow 22000/tcp
- You need to ensure Synching has been installed and configured on all systems. After that, _each device must be told about the other devices by exchanging device IDs. Obtain your Device ID (Server Ubuntu): Actions, Show ID (Copy). Client Mac: Add Remote Device, Device ID (Paste), Device Name (LinuxServer).
- Refresh the Web interface on the first device, the Ubuntu server. You will see the following message: Device…. wants to connect. Add new device? Click on Add Device (Device Name: MacClient) and wait patiently till Remote Devices, MacClient (Up to Date).
- We can synchronize two folders now. Click the Add Folder to add a new folder and give it a descriptive label and set the folder path (/mnt/discoExterno/documentos). On the Sharing tab, select MacClient.
- You need to wait till you see a message in your MacClient: LinuxServer wants to share folder “documentos”. Add new folder? Select Add, and define Folder Path.
rsync
rsync lets you transfer and synchronize data between different machines and directories. A good example is rsync -av ‐‐delete /home/myUser/Dropbox/ /mnt/discoExterno/.
Most common options are:
- -a, ‐‐archive, recursion and preserve almost everything, that is, preserves permissions, ownership, timestamps, and recursively copies directories.
- -r, ‐‐recursive: recursively syncs directories and their contents.
- -z, ‐‐compress: Compresses data. It’s particularly useful for efficiently transferring data between local and remote systems.
- ‐‐dry-run: Perform a trial run without making any changes. It is useful for testing without any risks of losing information.
- ‐‐delete: It synchronizes the local and remote directory. It will delete files in the destination directory if they don’t exist in the source directory.
- ‐‐v. Increases verbosity.
- ‐‐exclude. Exclude files or directories, e.g., rsync -av –exclude ‘file.txt’ /path/to/source /path/to/destination or rsync -av –exclude ‘dir1/’ /path/to/source /path/to/destination.
- ‐‐exclude-from=&$HOME/.exclude_me.txt. If the number of the files and/or directories you want to exclude is large, instead of using multiple ‐‐exclude options you can specify the files and directories you want to exclude in a file. It is easy to read and maintain:
vim .exclude_me.txt
$HOME/yay/
$HOME/.cache/
$HOME/.cache/paru/clone/brave/*
$HOME/.local/share/containers/storage/*
👁 If you include a trailing slash / at the end of a directory path, rsync will synchronize the contents of that directory, but not the directory itself. If you omit it, rsync will synchronize the entire directory, including its contents and the directory itself.
Futhermore, rsync can transfer and synchronize files and directories from and to remote servers: rsync -av ‐‐delete /path/source username@remotehost:/path/destination.
Troubleshooting:
user@pc:~$ rsync -a --exclude-from=&$HOME/.exclude_me.txt --delete $HOME /run/media/nmaximo7/mydisk1/myLinux
rsync: [sender] opendir "&$HOME/.cache/paru/clone/brave/pkg" failed: Permission denied (13)
IO error encountered -- skipping file deletion
There are many options: run rsync as a superuser with sudo, check ownership and permissions (sudo chown, sudo chmod), ensure that the destination directory has the correct permissions and is writable by the user running rync and always, double-check the paths specified in the ‐‐exclude options to make sure they match the directories you want to exclude.
In my particular case, I did not have the privilege to remove directories and files in the destination (I am doing a cloning), so I remove then with sudo.
Backup hardware
Dual bay hdd docking stations like Tacens Portum Duo II allow you to access and transfer data simultaneously between your computer and two SATA hard drives as if they were installed inside the computer or clone drives offline at faster transfer speeds.The OTB function, i.e., One Touch Backup lets you backup your data by just pressing one button. It is as easy as it gets, just follow the next steps:
- Put the source and the destination disks into the A and B bays respectively. Make sure that the power adapter is connected and powered on.
- Press the CLONE button, and keep on pressing it for three seconds to begin duplication.
- When the green, red, yellow, and orange LEDs all stay solid, the clonation process is done. Next, you may want to press the power button to turn off the docking station and remove your drives from the dock.
Be careful, your drives may be very hot after the cloning process.