Using rsync, allows to have incremental backup.
The basic command is:
rsync -[flag] –exclude={“/exclude/pathOne/”,”/exclude/thisPathToo/”} [source/to/backup] [destination/to/store/backup]
Run this command to backup in /mnt/SSD1/backups
time sudo rsync -aAXvz –delete –exclude={“/dev/”,”/proc/”,”/sys/”,”/tmp/”,”/run/”,”/mnt/”,”/media/*”,”/lost+found”} / /mnt/SSD1/backups/main_backup
Alternative with tar to create a compress backup
time sudo tar -czvf /mnt/SSD1/backups/$backup_name.tar.gz –exclude={“/dev/”,”/proc/”,”/sys/”,”/tmp/”,”/run/”,”/mnt/”,”/media/*”,”/lost+found”} /
| flag | action |
|---|---|
| -a | archive mode (preserves permissions, ownership…) |
| -A | Preserve ACLs (Access Control Lists) |
| -X | Preserve extended attributes |
| -v | Verbose output (optional, for seeing progress) |
| -z | Make it faster (compress the transfer, but not the final files) |
| –delete | Make an incremental backup, |
If using rsync over ssh, you might want to use the --numeric-ids flag
To restore with rsync, run the same command but reverse the source and destination:
sudo rsync -aAXvz –delete –exclude={“/dev/”,”/proc/”,”/sys/”,”/tmp/”,”/run/”,”/mnt/”,”/media/*”,”/lost+found”} /mnt/SSD1/backups/main_backup /
If the system is not accessible, a backup can be made from a live preview of the os. In that case:
mkdir /mnt/drive
lsblkmount /dev/device/partition/name /mnt/drive
sudo rsync -aAXvz –delete –exclude={“/dev/”,”/proc/”,”/sys/”,”/tmp/”,”/run/”,”/mnt/”,”/media/*”,”/lost+found”} /mnt/SSD1/backups/main_backup /