How to make full backup of Ubuntu Server (tar vs rsync)
#1 This is the easiest and the dumbest way of backing up your data, by running this command you simply create full image of your operating system at certain point in time. Pay attention to extra flags, I’m excluding backup file, you don’t want tar running in endless loops.
1 |
tar -cvpzf full_backup.tar.gz --exclude=/full_backup.tar.gz --one-file-system / |
In depth description of what is going on here can be found in the official ubuntu documentation.
#2 Next time you run command above, it will create yet another full backup of your system – but some files will probably not change at all, so it is quite pointless to have trillion copies of the same unmodified file. So what do we do if we don’t have unlimited space and time? Introducing incremental (delta) backup tool rsync.
Rsync is a protocol built for Unix-like systems that provides unbelievable versatility for backing up and synchronizing data. It can be used locally to back up files to different directories or can be configured to sync across the Internet to other hosts.
1 |
rsync -av --delete /project1/ /backups/project1/ |
The code above will synchronize the contents of /project1/ to /backups/project1/, and leave no differences between the two. If rsync finds that /backups/project1/ has a file that /project1/ does not, it will delete it. If rsync finds a file that has been changed, created, or deleted in /project1/, it will reflect those same changes to /backups/project1/.
As I already mentioned rsync can be used to backup files from 1 server to the other. I will cover this in my next article.
Leave a Reply