Many new features now available including 2-Factor authentication

Backing up w/ rsync

Started by olddarling, October 31, 2020, 05:38:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


Hello gang

I have an Ubuntu server at home that I use for a few things (file server, media server etc.) and I'm having trouble backing it up properly. As background, I recently tried to install and config OwnCloud and messed it up so tried to delete/ uninstall and that made it worse. I'm now getting errors all over the place so today cut my losses and have done a fresh install of Ubuntu. This made me realise I need a backup strategy...

I'd like to be able to back up my system files and roll-back to a version of the system that I know works if I mess up another installation in the future (I'm not worried about /home files I just copy important stuff to a separate external drive every so often).

I tried using rsync to backup my fresh install of ubuntu but it didn't work as expected, here are the steps I took:

I installed Glances and enabled the UFW.

I created a directory /backups/basic.

I backed the system up using the following command sudo rsync -avzP / --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/backups/*","/media/*","/lost+found","/home/*"} /backups/basic

I then uninstalled Glances and disabled UFW.

I then attempted to restore the backup with the command sudo rsync -avP /backups/basic --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/backups/*","/media/*","/lost+found","/home/*"} / (note I removed -z option as I don't want the restored files to be compressed, I think that's right?).

My expectation was that, after restore and reboot, Glances would still be installed and the UFW would still be enabled. But Glances wasn't installed and the UFW was disabled. So it seem like the backup was unsuccessful.

So, my question is, have I done this wrong or am I just expecting something different to what rsync provides?

My setup is:
Ubuntu server 20.04 LTS
1gb SSD mounted to /
2x2Tb HDDs (RAID 0) mounted to /home

Thanks in advance,

UPDATE: the reason the backup wasn't working is because of the 'trailing /'. As there was no / on the end of the /backups/basic source it was creating a new directory /basic instead of updating the contents of /. The commands I used to backup and restore were:

sudo rsync -aAXH --info=progress2 --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/backups/*","/media/*","/lost+found","/home/*"} / /backups/basic

sudo rsync -aAXH --info=progress2 --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/backups/*","/media/*","/lost+found","/home/*"} /backups/basic/ /


I use grsync rather than just rsync. It gives a graphical interface which is more useful (for me) as you can easily decide on the source and destination for your backup. It is available in Synaptic. Hope that might help




I use rsync regularly but without compression (just normal files) but as far as I know rsync doesn't have an unzip feature, which you will need to do before rsync-ing from the backup - that's why there was no sign of your files. 
In addition you won't need the --exclude option when rsync-ing from the back-up because they are not on the back-up anyway. 

Perhaps tar would be the best option as it has an un-zip facility and is very versatile.  Never used it myself but worth a look.


Mad Penguin

Rsync is great but I no longer use it for backups, so another option you might want to take a look at;
https://www.borgbackup.org/ (https://www.borgbackup.org/)