sudo rsync -avxHAX --progress --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/home/*/.cache/*","/var/cache/*","/var/tmp/*"} / /path/to/backup/destination/
Let's break down this rsync command:
-
sudo
: Run the command with root privileges, necessary for accessing all system files. -
rsync
: The command itself. -
Options:
-a
: Archive mode, which preserves almost everything-v
: Verbose, for more detailed output-x
: Don't cross filesystem boundaries-H
: Preserve hard links-A
: Preserve ACLs (Access Control Lists)-X
: Preserve extended attributes--progress
: Show progress during transfer
-
--exclude={}
: This excludes certain directories that are either unnecessary for backup or could cause issues if included:/dev/*
,/proc/*
,/sys/*
: Virtual filesystems/tmp/*
,/run/*
: Temporary files/mnt/*
,/media/*
: Mount points/lost+found
: Used by fsck/home/*/.cache/*
,/var/cache/*
,/var/tmp/*
: Cache directories
-
/
: The source directory (root of the filesystem) -
/path/to/backup/destination/
: Replace this with the actual path where you want to store the backup
To use this command:
- Replace
/path/to/backup/destination/
with your actual backup location. - Run the command in a terminal.
Some important notes:
- Ensure your backup destination has enough space.
- This backup will take a significant amount of time, depending on your system size and backup destination speed.
- Consider running this in a screen or tmux session if you're doing it over SSH, to prevent interruption if your connection drops.
- You might want to add or remove exclusions based on your specific needs.
Would you like me to explain any part of this command further or discuss strategies for scheduling regular backups?