Originally Posted by Hern_28
Do you have a how to or a link to one where i can rsync linux to another partition and keep 2 working copies of my system?
There are a lot of guys who know a lot more than me on this forum so I didn't consider any how-to. I usually try to help out on the multibooting questions since I do a lot of that.
Basically what rsync is is program that copies stuff over a tcp connection. They added a lot of features to make it smarter and it can tell if a file has been modified from the source. I got started on this project by using rsync on the command line to make sure I understood what it was doing. There are a lot of options but the main ones to use to get started without doing anything bad to yourself are -axvn.
-a means do an archive. it recurses into directories (gets everything) and saves the permissions and times.
-x means stay on a mounted filesystem. If you have a complicated setup with mounts to all kinds of other stuff (NFS shares, etc) you can really cause problems for yourself if you forget what you're doing so -x will keep you on the one mounted filesystem
-v means verbose, show all of what rsync is doing
-n means don't do anything, it just goes through the motions of finding and comparing files but doesn't do anything. You can use all these options to check if rsync is understanding your command like you want it to.
The other thing that's important with rsync is to use trailing / for directories. If not, you can get files all over the place. There are some simple example commands in the rsync man page, just remember to always use -vn to see what you're doing and you won't hurt yourself.
What I did was to create partitions the same size as I wanted to back up. If you have mountpoints for root (/) home and opt for example, create three partitions and make filesystems in each one.
Then you can have a script that does something like
mount /dev/hdx /mnt/altroot
rsync -axv --exlude-from=my.exclusion.file // /mnt/altroot/
and do a set of these for each partition.
The exclusion file is a nice way to be able to prevent copying junk you don't want. All the stuff like your .Xauthority files and whatever other things you don't need to waste time copying can be entered into a text file and then you can use that as input to rsync.
The other thing that's nice about rsync is it can delete stuff on the receiving filesystem if the sending filesystem doesn't have it. For example if you have tons of emails you get every day and you keep backing up your system, all this junk will accumulate on your backup system, because you didn't do anything to delete it. So you can add --delete to your rsync command and it will first delete everything on the target filesystem that doesn't show up on the source filesystem, and then copy whatever needs to be backed up. You can change the order to delete it last, etc. Deleting it first is the default and it's a pretty nice idea since after you delete the files you don't need there will be more space for what you do need.
To get something like this working is not a big deal. You have to know what you want to backup and what you don't need to back up. You have to play around with rsync and cron a little to get the idea of how often you want to back up and what exactly you have to do for commands. Start with a simple script and make sure you check all the exit codes from whatever you run. Try to boot into your secondary system to make sure everything is there. Hint: you will want to exclude fstab after the initial copy! It's a good idea to use rsync to copy the whole system the first time and then decide what you don't want to modify, etc.