LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   thoughts on restore from an rsync "image" (https://www.linuxquestions.org/questions/linux-software-2/thoughts-on-restore-from-an-rsync-image-676233/)

moob8 10-14-2008 07:03 AM

thoughts on restore from an rsync "image"
 
Note:

In this post I'll be using the term "attributes" to refer to the various properties of files. Files can include files, directories, nodes, fifos, whatever linux thinks a file is. By "attributes" I mean the read/write/etc flags, as well as ownership, group, file date, suid, and whatever other flags/stuff linux has on each file.

Background:

In the past I've used tar (booted off a livecd) to to do a complete and total backup of my linux. I've had hard drive failures and/or data migrations that caused me to restore from the tar backups (thus testing/verifying this method). They worked fine. All file attributes were correctly preserved. Whew: it worked!

Complete and total tar of a linux system is a bit of a PITA so I decided to use rsync to make a quicker weekly (or so) backup of the running system to an external drive. benefits: (1) only the files changed are written to (or deleted from) the external disk, saving a lot of time and (2) I can run it within the running linux.

I then had a hardware problem which necesitated a wipe and restore. From a livecd I copied the files from the external drive onto the new HD. To insure a proper copy (IE, to preserve ALL file attributes) I piped two tar processes instead of using cp.

In the new restored system, I've been having problems which I have been fixing, one at at time. First, there was no dev and no proc directory. I'd told rsycn to skip them for reasons that made sense at the time. Making a dev and proc allowed the kernel to boot without panic. Xorg refused to run and it turned out (from a google search) that I needed to perform a chmod for "u+s" on the actual Xorg program itself. su doesn't work for non-root and I don't have the ability to access the sound device. My guess is that some sort of protection/attribute thing was lost to some files during the rsync and that I will stumble onto additional problems.

So ... to the actual specific questions
  • Can rsync be used to do a total backup (ie, all files, and all flags/attributes) that can later be used to do an total restore to a blank partition?
  • If the answer to above is a "yes", what command line arguments did you pass to rsync? How did you run rsync?
  • Based on all I have written, what files/dirs in my system need their attributes/protection changed? And in what way?
Thank you in advance.

chrism01 10-14-2008 07:42 PM

Quote:

From a livecd I copied the files from the external drive onto the new HD.
I don't think you're supposed to do that. You're supposed to use the 'Install to HDD' option if there is one.
/proc is a window into the kernel, you shouldn't try to copy it, its pointless. /dev is the device drivers.
The install will create those 2 dirs (and others eg /var /home etc) for you.

Basically you install the OS, then restore your personal progs/data and any customised configs etc.

gilead 10-14-2008 10:19 PM

What command did you use to rsync the data to the external drive? I use something like this:
Code:

/usr/bin/rsync --archive --delete --progress /[a-o]* /zzz/20081015
/usr/bin/rsync --archive --delete --progress /[q-r]* /zzz/20081015
/usr/bin/rsync --archive --delete --progress /sbin /zzz/20081015
/usr/bin/rsync --archive --delete --progress /[t-y]* /zzz/20081015
mkdir -pv /zzz/20081015/{proc,sys}
chmod 0555 /zzz/20081015/proc
chmod 0755 /zzz/20081015/sys

--archive means it preserves permissions and file-types, it's the same as -rlptgoD according to the man page. To copy them back you could either use rsync again or cp -a

sfxpt 10-15-2008 09:15 AM

Quote:

Originally Posted by moob8 (Post 3309644)
  • Can rsync be used to do a total backup (ie, all files, and all flags/attributes) that can later be used to do an total restore to a blank partition?
  • If the answer to above is a "yes", what command line arguments did you pass to rsync? How did you run rsync?
  • Based on all I have written, what files/dirs in my system need their attributes/protection changed? And in what way?

1 - Yes, absolutely.

2 - rsyn -vuaCH --delete --delete-excluded

Note -H is *very* important! and you might want to omit the -v.

3 - Nothing, if the above rsyn cmdl is used. Just make sure your backup disk is of Linux format, not brain-deaded Windoze fat ones.

Also, FYI, rsyn can allows you to do incremental backups as well. So you can restore to any backup time, without taking too much of the backup space. Check rdiff-backup.

moob8 10-16-2008 09:18 AM

Thanks for the replies. I'm still digesting them (must consult man pages to see what the rsync switches mean in your replies, etc.).

I'd still like to get this to wok for future restores. The tried and true method of taring the liinux (while booted off a live cd) just takes so long and it ties the machine up.

p.s. the rsync command from my backup script was ....
Quote:

rsync \
--exclude-from=/root/pcc_rsync_skip_dirs.txt \
--delete --specials --devices --progress -rlHptgo \
. $USE_DIR/nix_backup 2>> /root/pcc_backup_log.txt && \
where use dir is the name of the mounted direcotry of the external HD to backup to (which is ext3, btw, so that all permissions and stuff can (in theory) be retained correctly).


All times are GMT -5. The time now is 06:06 PM.