Linux Backup
Mount the external on /mnt/sdX1
, for example. cd
to /
, then, use:
sudo rsync -aAXv / --delete --dry-run --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /mnt/sdX1
For my own memory, lately I've been using:
sudo rsync -aAXv /home/czw --delete --exclude="/czw/yay" --exclude="/czw/snap" /mnt/sdb1/02-03-2021/
To restore from a live usb, mount the backup disk on /mnt/sdX1
and mount the system disk on /mnt/sdY
for example. Then run rsync in the reverse of above:
sudo rsync -aAXv /mnt/sdX1/ /mnt/sdY/ --delete --dry-run --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"}
Note the trailing slash in the above.
1. For backing up my home directory
sudo rsync -aAXv /home/czw --delete --dry-run --exclude="/czw/yay" --exclude="/czw/snap" --exclude="/czw/anaconda3" /mnt/sdb1/02-03-2021/
2. Useful links
- How to mount and rsync
mount /dev/sdb1 /mnt/db1
- Exclude multiple directories - note that the syntax differs between shells
- Make sure to exclude from the root of transfer - if syncing from
/home/czw
, then/czw/
is the root of transfer to start all your exclusion paths from