Author Topic: Backing up w/ rsync  (Read 360 times)

0 Members and 1 Guest are viewing this topic.

Offline olddarling

  • Jr. Member
  • **
  • Posts: 1
  • Karma: 0
  • I've just joined!
    • View Profile
    • Awards
Backing up w/ rsync
« on: October 31, 2020, 05:38:05 pm »
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,
olddarling

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/ /
« Last Edit: November 01, 2020, 06:54:49 pm by olddarling »

Offline wishbone

  • Jr. Member
  • **
  • Posts: 74
  • Karma: 4
  • I've just joined!
    • View Profile
    • Awards
Re: Backing up w/ rsync
« Reply #1 on: October 31, 2020, 10:15:58 pm »
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

Tony

The Linux Community Forum

Re: Backing up w/ rsync
« Reply #1 on: October 31, 2020, 10:15:58 pm »

Offline Keith

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1173
  • Karma: 19
  • Gender: Male
  • Linux Novice
  • Awards Contributor Of The Month
    • View Profile
    • Awards
Re: Backing up w/ rsync
« Reply #2 on: November 01, 2020, 02:31:35 pm »
OD,

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.

Keith

Offline Mad Penguin

  • Administrator
  • Hero Member
  • *****
  • Posts: 1474
  • Karma: 10024
  • Gender: Male
    • View Profile
    • Awards
Re: Backing up w/ rsync
« Reply #3 on: November 01, 2020, 02:49:38 pm »
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/

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal