Back Up Your Linux Operating System With Rsync

If you’ve been using Linux for a while, you already know that everything is a file. What if I told you you could back up your ENTIRE operating system without installing a single additional package? Well, it’s true. The rsync command has enough command line options to make the perfect backup tool. The best part about this is an option to have it run automatically as a cron job – updating only the files that it needs to on the target drive.

For those of you who would prefer to copy and paste the command without further ado: (Replace /mnt/target_dir with your target directory)

If anyone’s still reading, that command will copy symbolic links instead of following them! the ‘delete’ flag instructs it to delete files in the target that don’t exist in the source directory. To restore your Linux distribution, cd into the target directory and run the same command without any arguments after theĀ -aAXvu grouping, and swap the target for the root of your hard drive. The hard drive must be identical to the one rsync copied from – if it’s not, you’ll have to update your fstab and re-generate your grub config.