Full System Linux backup with rsync via ssh to other computer

I would like to do a full system backup analogously to this thread:

https://askubuntu.com/questions/7809/how-to-back-up-my-entire-system

...however, not with creating tarballs, but with rsync - and from one computer to the other over local network, via ssh. I have followed the steps and in principle, it works ok up to some point, where probably, file permissions play a role.

I have set up the rsync as follows:

rsync -aAXv userOnSource@sourceIP:/ /home/MYBACKUPFOLDER

I will exclude certain folders like /sys and /proc (as one should) next time, but the problem lies in the fact that also, some folders in e.g. /etc and /usr/share throw a permission denied error and aren't copied.

My question is thus: How do I set up rsync such that it copies everything desired, and given that I renew my old computer with the same linux distribution (in my case, ArchLinux) and create the same users, how do I preserve the file attributes and permissions when I copy back the backup to the newly installed machine?

Pro question: What else would be needed if I have yet a third machine to send the backup to?

Thanks!


Solution 1:

Here is my script,fyi.

sudo rsync -avAX --delete --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/swapfile","/home/*/.thumbnails/*","/home/*/.cache/*"} / /mnt/rootfs

Would suggest to consider the following steps,

  1. Do disk/partition clone if possible;
  2. Run the above script on source PC, otherwise SSH config may cause issues for root user access;
  3. Backup to mounted USB harddisk or local foler (must be excluded) if possible, later you will have option to compress it before transfer out.