Daerandin
Well-Known Member
I just wanted to share something I consider to be a very easy and good way of keeping backups using something called rsync. It is well known and should be available in official repos for most distros.
If you have an external drive, or another partition that you use specifically for backups, you can easily make a full system backup with a single command. As long as the storage media for your backup is a Linux filesystem (such as ext4, NOT fat32 or ntfs), then this will work. Everything in Linux is a file, and as long as file permissions and ownership is retained then it will yield a functional backup which can be used to restore the full system to a previous point.
The command is fairly simple, just make sure to run it as root (or with sudo):
It is very important that the location you backup to, is located in /media or /run, if not then you must make sure to specify the backup location among the excluded directories.
This will retain all file permissions and ownership. The excluded directories are populated on boot, which is why you should not copy their contents when doing a backup, and lost+found is filesystem specific.
This can be run again, pointing to the same backup directory, and it will simply update the backup to the current system state, which will take much shorter time than the initial backup. The --delete option is important if you want the backup to always mirror your current system state as it will delete old files from a past backup that no longer exist on your system when doing a new backup.
You can then easily grab lost files from the backup if needed, or even do a complete system restore at a later point by running the above command, but instead of
You change their place to look like this:
And your full system will revert to the exact state as when the last backup was done.
If you have an external drive, or another partition that you use specifically for backups, you can easily make a full system backup with a single command. As long as the storage media for your backup is a Linux filesystem (such as ext4, NOT fat32 or ntfs), then this will work. Everything in Linux is a file, and as long as file permissions and ownership is retained then it will yield a functional backup which can be used to restore the full system to a previous point.
The command is fairly simple, just make sure to run it as root (or with sudo):
Code:
rsync -aAXv --delete /* /path/to/backup/directory --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}
It is very important that the location you backup to, is located in /media or /run, if not then you must make sure to specify the backup location among the excluded directories.
This will retain all file permissions and ownership. The excluded directories are populated on boot, which is why you should not copy their contents when doing a backup, and lost+found is filesystem specific.
This can be run again, pointing to the same backup directory, and it will simply update the backup to the current system state, which will take much shorter time than the initial backup. The --delete option is important if you want the backup to always mirror your current system state as it will delete old files from a past backup that no longer exist on your system when doing a new backup.
You can then easily grab lost files from the backup if needed, or even do a complete system restore at a later point by running the above command, but instead of
Code:
/* /path/to/backup/directory
You change their place to look like this:
Code:
/path/to/backup/directory/* /
And your full system will revert to the exact state as when the last backup was done.