Personal backups with ‘rsync’
Our data is our digital lives. If we lose our data, we lose more than just a few files—personal data can include photos, resumes, and hobby projects. If your primary computer is a laptop, consider that you take your personal data with you everywhere, and you can lose all of that if your laptop is stolen, lost, or damaged.
At a minimum, you need good backups. Don’t overthink your backup strategy: just making a copy of your files to a USB flash drive once a week, and putting that drive in a drawer, can save you if you lose your data.
Making backups with ‘rsync’
An easy and reliable way to make a backup is to “drag and drop” files and folders in the file manager to copy your data to the second drive. But this method may not preserve all of the attributes of your files. If you want to keep permissions and file creation dates, you need a different method. That’s where the rsync command comes in.
The rsync command was originally invented to synchronize files between two remote systems. That’s where the name came from: remotely synchronize between systems. But you can just as easily use rsync to synchronize files between two directories: your home directory and a “backup” directory.
Making a backup with rsync is just a two-step process: prepare the backup directory, and run the backup with rsync.
1. Prepare the backup directory
Start by plugging in a USB flash drive to your Linux system. Your file manager should automatically recognize it and make it available for use (a process called “mounting”). The default “mount” location is under the /run/media
path, plus your username, then the name of the drive. For example, my backup drive gets mounted as /run/media/jhall/Backup
.
Open a terminal window, and make a new directory on the drive to make your backups. I like to use the date for my backup directory, such as this command to make a backup on January 15:
$ mkdir /run/media/jhall/Backup/2025-01-15
2. Run the backup
Now you’re ready to make a backup of your files with the rsync command. To make a backup, you just need one option: -a will use “archive mode,” but you can think of this option as “all” because it saves everything. Using -a means the backup runs recursively (same as -r) and saves links as links (same as -l) and preserves all permissions (same as -p). It also keeps timestamps (same as -t) and group and owner permissions (same as -g and -o) and any special device information (same as -D). You don’t have to specify the -r -l -p -t -g -o -D options, using -a does all of that for you. To make the backup, type this command:
$ rsync -a $HOME/ /run/media/jhall/Backup/2025-01-15/
If the directory name ends with a slash, rsync will recognize it as a directory and copy everything in it.
How long this backup takes will depend on how much data it needs to copy and the speed of the backup device. My backups take about ten minutes. After you make the backup, use your file manager to safely remove the flash drive from the system. Most file managers will have an “eject” icon next to a removeable drive; clicking this will tell the system to stop using the drive (called “unmounting”).
Personal backups with ‘rsync’
By making backups using rsync, your files are copied to the destination, preserving all permissions. You don’t have to go through a complicated process or run other commands to restore your data in case of a loss. You can simply copy the files and folders you need. That makes it easy to restore just a few files at a time, in case you accidentally delete or overwrite one or two important files by accident. Just navigate to those files on the backup drive, and copy them back to your home directory.
My Linux home directory is about 19GB, which I can easily fit on a 32GB USB flash drive, although for not much more, you can buy a 128GB USB flash drive for about $20 or $25. I recommend you get two of them so you always have a second copy of your data. For less than $50 total, you can safely protect your data from total loss.