I am looking into using rsync to make a copy of my existing home directory(1.6Gb) and storing an exact copy on another local drive. I have had a look at the man pages for rsync and notice that there are tons of options. I have noted the options I would like below and ask for some assistance in compiling the correct syntax of the coammand. I will be running the cmd as root from a root terminal(Alt-F2) and the user in question will not be logged on at the same time. The switches I have identified are: -v - Verbose @ I'd like to know what is happening -c - always checksum # This makes sure the file on SRC is the same as DEST -r - recurse into directories # All the files in the subdirectories -l - copy symlinks as symlinks # Should there be any if I haven't created any, to my knowledge -A - preserve ACLs (implies -p) [local option] #preserve permissions -o - preserve owner -g - preserve group -t - preserve times #preserve the time the file was last edited --stats - give some file transfer stats #Stats on what happened -a - archive mode, equivalent to -rlptgoD The command so far: #rsync -vcrlAogt -stats /home/hylton /media/backup/ I would like the entire contents of /home/hylton copied to a hylton directory on /media/backup. Would this cmd achieve this? Should I swop some options out and rater use -a? Do I need D? ie the command would be: #rsync -vcA -stats /home/hylton /media/backup/ Does the first try at the command look right as I am wondering about the -stats option. -- ======================================================================== Hylton Conacher - Linux user # 229959 at http://counter.li.org Currently using SuSE 9.2 Professional with KDE ========================================================================
On Wed, 2006-03-29 at 18:04 +0200, Hylton Conacher(ZR1HPC) wrote:
I am looking into using rsync to make a copy of my existing home directory(1.6Gb) and storing an exact copy on another local drive.
I have had a look at the man pages for rsync and notice that there are tons of options. I have noted the options I would like below and ask for some assistance in compiling the correct syntax of the coammand. I will be running the cmd as root from a root terminal(Alt-F2) and the user in question will not be logged on at the same time.
The switches I have identified are: -v - Verbose @ I'd like to know what is happening -c - always checksum # This makes sure the file on SRC is the same as DEST -r - recurse into directories # All the files in the subdirectories -l - copy symlinks as symlinks # Should there be any if I haven't created any, to my knowledge -A - preserve ACLs (implies -p) [local option] #preserve permissions -o - preserve owner -g - preserve group -t - preserve times #preserve the time the file was last edited --stats - give some file transfer stats #Stats on what happened -a - archive mode, equivalent to -rlptgoD
The command so far: #rsync -vcrlAogt -stats /home/hylton /media/backup/
I would use rsync -varpltz --stats /home/hylton/ /media/backup/home Make sure you include a closing / on the source so that you get a recursive copy. I also doubt your home directory has any special ACL's that need backup. This could also be used by the owner of the files which in this case would be hylton. -- Ken Schneider UNIX since 1989, linux since 1994, SuSE since 1998
On Wednesday 29 March 2006 13:34, Ken Schneider wrote: [snip]
I would use rsync -varpltz --stats /home/hylton/ /media/backup/home
Make sure you include a closing / on the source so that you get a recursive copy.
That's not what the closing / does. According to the man page, a trailing / on the source changes the behavior so that "You can think of a trailing / on a source as meaning 'copy the contents of this directory' as opposed to 'copy the directory by name' " Recursive copying is controlled by -r. In your example, the contents of /home/hylton would be copied to /media/backup/home. There would be no /media/backup/home/hylton directory created--probably not what the OP expects. Jim
On Wed, 2006-03-29 at 13:56 -0800, Jim Cunning wrote:
On Wednesday 29 March 2006 13:34, Ken Schneider wrote: [snip]
I would use rsync -varpltz --stats /home/hylton/ /media/backup/home
Make sure you include a closing / on the source so that you get a recursive copy.
That's not what the closing / does. According to the man page, a trailing / on the source changes the behavior so that "You can think of a trailing / on a source as meaning 'copy the contents of this directory' as opposed to 'copy the directory by name' " Recursive copying is controlled by -r.
In your example, the contents of /home/hylton would be copied to /media/backup/home. There would be no /media/backup/home/hylton directory created--probably not what the OP expects.
It is fine to critique someone, but where is your example of what -you- would use. What has your experience of rsync shown to be a better way to use it? -- Ken Schneider UNIX since 1989, linux since 1994, SuSE since 1998
On Wed, 2006-03-29 at 13:56 -0800, Jim Cunning wrote:
On Wednesday 29 March 2006 13:34, Ken Schneider wrote: [snip]
I would use rsync -varpltz --stats /home/hylton/ /media/backup/home
Make sure you include a closing / on the source so that you get a recursive copy.
That's not what the closing / does. According to the man page, a trailing / on the source changes the behavior so that "You can think of a trailing / on a source as meaning 'copy the contents of this directory' as opposed to 'copy the directory by name' " Recursive copying is controlled by -r.
In your example, the contents of /home/hylton would be copied to /media/backup/home. There would be no /media/backup/home/hylton directory created--probably not what the OP expects.
It is fine to critique someone, but where is your example of what -you- would use. What has your experience of rsync shown to be a better way to use it? I didn't think it was necessary to provide a more explicit example than to quote the man page. It was quite clear to me, and if not to others, then 'man rsync' is their friend. In fact, a few lines below what I quoted, the man
On Wednesday 29 March 2006 14:53, Ken Schneider wrote: page gives two ways to accomplish the same thing. It was also not my intent to say "I have a better way to use rsync." Whatever works for you is fine with me. I merely was pointing out that your example might not achieve what the OP wanted. But since you want a better way from my experience, 1. -varpltz is overkill. Because -a implies -rpltzgoD, using -vaz would be sufficient. 2. -z doesn't make sense in the application you suggest, since both source and destination are "local" (neither contains a ':') 3. My preferred way to replicate/backup a directory (_and_ all its contents) is to do rsync -e ssh -zvaP /path/to/source/directoryX backuphost:/path/to/backup/dir I would expect to see 'directoryX' in /path/to/backup/dir 4. My version of your example would be rsync -vaP /home/hylton /media/backup/home -- Jim Cunning UNIX since 1981, linux since 1992, SuSE since 1998
Jim Cunning wrote:
On Wednesday 29 March 2006 14:53, Ken Schneider wrote:
On Wed, 2006-03-29 at 13:56 -0800, Jim Cunning wrote:
On Wednesday 29 March 2006 13:34, Ken Schneider wrote:
1. -varpltz is overkill. Because -a implies -rpltzgoD, using -vaz would be sufficient. 2. -z doesn't make sense in the application you suggest, since both source and destination are "local" (neither contains a ':') 3. My preferred way to replicate/backup a directory (_and_ all its contents) is to do rsync -e ssh -zvaP /path/to/source/directoryX backuphost:/path/to/backup/dir I would expect to see 'directoryX' in /path/to/backup/dir 4. My version of your example would be rsync -vaP /home/hylton /media/backup/home
Two other suggestions for the OP: (1) don't forget the -n or --dry-run option if you're nervous (2) if you're still nervous, try copying a small directory and checking the result before copying everything Don't worry, you won't lose the original data. If you don't like the result, just delete it and start again. Cheers, Dave
Jim Cunning wrote:
On Wednesday 29 March 2006 14:53, Ken Schneider wrote:
On Wed, 2006-03-29 at 13:56 -0800, Jim Cunning wrote:
On Wednesday 29 March 2006 13:34, Ken Schneider wrote:
1. -varpltz is overkill. Because -a implies -rpltzgoD, using -vaz would be sufficient. 2. -z doesn't make sense in the application you suggest, since both source and destination are "local" (neither contains a ':') 3. My preferred way to replicate/backup a directory (_and_ all its contents) is to do rsync -e ssh -zvaP /path/to/source/directoryX backuphost:/path/to/backup/dir I would expect to see 'directoryX' in /path/to/backup/dir 4. My version of your example would be rsync -vaP /home/hylton /media/backup/home
Two other suggestions for the OP:
(1) don't forget the -n or --dry-run option if you're nervous Nervous as hell :) but easing off after such fine critiques. Would I put
Dave Howorth wrote: the -n option in as another switch so that rsync would do all the other switches but only 'play play' ie not actually move data?
(2) if you're still nervous, try copying a small directory and checking the result before copying everything That requires more /'s or lack thereof. I'll try a small directory like /etc :)
Don't worry, you won't lose the original data. If you don't like the result, just delete it and start again. mmm Thanks. I'll sleep a whole lot better tonight after all it is only a copy of the data not a cut and move of the data. (sorry old Windows methods die VERY slowly here).
-- ======================================================================== Hylton Conacher - Linux user # 229959 at http://counter.li.org Currently using SuSE 9.2 Professional with KDE ========================================================================
On Wed, 2006-03-29 at 15:55 -0800, Jim Cunning wrote:
3. My preferred way to replicate/backup a directory (_and_ all its contents) is to do rsync -e ssh -zvaP /path/to/source/directoryX backuphost:/path/to/backup/dir I would expect to see 'directoryX' in /path/to/backup/dir 4. My version of your example would be rsync -vaP /home/hylton /media/backup/home
So for drive to drive with the second drive mounted at /home/<user>/TEMPTEMP to a spare partition: rsync -vaP /home/<user>/TEMPTEMP /Storeage0 -- ___ _ _ _ ____ _ _ _ | | | | [__ | | | |___ |_|_| ___] | \/
Ken Schneider wrote:
On Wed, 2006-03-29 at 13:56 -0800, Jim Cunning wrote:
On Wednesday 29 March 2006 13:34, Ken Schneider wrote: [snip]
I would use rsync -varpltz --stats /home/hylton/ /media/backup/home
Make sure you include a closing / on the source so that you get a recursive copy.
That's not what the closing / does. According to the man page, a trailing / on the source changes the behavior so that "You can think of a trailing / on a source as meaning 'copy the contents of this directory' as opposed to 'copy the directory by name' " Recursive copying is controlled by -r.
In your example, the contents of /home/hylton would be copied to /media/backup/home. There would be no /media/backup/home/hylton directory created--probably not what the OP expects.
It is fine to critique someone, but where is your example of what -you- would use. What has your experience of rsync shown to be a better way to use it? Now now children.. :)
Ken I wanted the critique as it helps me learn. Jim was only treationg you the same way you treated me in replying to my OP. Your critique/opinion was very good but we are all here to learn. Perhaps Jim is mistaken, perhaps not. Jim's critique helps you learn too I would think as surely the man page isn't wrong? I'm not saying he is right and I am not saying you are right. I am asking for everyones critiques/opinions on what works as we all know with Linux one incorrectly placed rm * can ruin alot of good data, so the end result has to be critiqued until it is correct and tried real time. All for the greater good and all that stuff etc etc -- ======================================================================== Hylton Conacher - Linux user # 229959 at http://counter.li.org Currently using SuSE 9.2 Professional with KDE ========================================================================
On Wednesday 29 March 2006 13:34, Ken Schneider wrote: [snip]
I would use rsync -varpltz --stats /home/hylton/ /media/backup/home
Make sure you include a closing / on the source so that you get a recursive copy.
That's not what the closing / does. According to the man page, a trailing / on the source changes the behavior so that "You can think of a trailing / on a source as meaning 'copy the contents of this directory' as opposed to 'copy the directory by name' " Recursive copying is controlled by -r.
In your example, the contents of /home/hylton would be copied to /media/backup/home. There would be no /media/backup/home/hylton directory created--probably not what the OP expects. Wow Jim tnx. How'd you know the OP didn't want it as you were right on
Jim Cunning wrote: the money :) So by leaving the src / off I get the /home/hylton directories in /media/backup? -- ======================================================================== Hylton Conacher - Linux user # 229959 at http://counter.li.org Currently using SuSE 9.2 Professional with KDE ========================================================================
Ken Schneider wrote:
On Wed, 2006-03-29 at 18:04 +0200, Hylton Conacher(ZR1HPC) wrote:
I am looking into using rsync to make a copy of my existing home directory(1.6Gb) and storing an exact copy on another local drive. .... <snip> The command so far: #rsync -vcrlAogt -stats /home/hylton /media/backup/
I would use rsync -varpltz --stats /home/hylton/ /media/backup/home
Make sure you include a closing / on the source so that you get a recursive copy. I also doubt your home directory has any special ACL's that need backup. This could also be used by the owner of the files which in this case would be hylton. Hi Ken,
Thanks for the input. I am not sure about your thoughts on the / as the man page tells otherwise (A trailing slash on the source changes this behavior to avoid creating an additional directory level at the destination. You can think of a trailing / on a source as meaning "copy the contents of this directory" as opposed to "copy the directory by name"....). I mainly did not put it there to avoid having to create a /media/backup/home/hylton directory as rsync would do it during its process. To explain it it in more detail: I want the entire contents of /home/hylton/ to be rsynced to /media/backup so that if I browse the /media/backup/ directory I am only going to see a home directory. Entering /media/backup/home will only present me with the hylton directory and finally entering /media/backup/home/hylton will present me with all the files, directories and subdirectories as they are laid out in my 'real' /home/hylton/ ie an EXACT replica. I have noted the differences that concern me between the options you and I have selected and comment below. As the only user on the system I agree to not storing the ACL's however for mirroring could it be added? Why would you not include the c option? Surely if the file on the source and destination have the same checksum and are therefore not transferred, it would speed up the total transfer? This is discussed in the 'Description' paragraph on the man page. I would like the copy on the original and backup to be identical so as to be up and running as quickly as possible. As I will be doing the rsync as root I would have thought that preserving the owner and group would be important. I noticed with a cp of the files that the ownership all reverts to root. I see that the inclusion of the p switch covers both o and g, thank you. As a drop in backup image of the /home/hylton directory I would like the file times to be kept the same as when the file was created/edited, not when it was copied. Would leaving out the -t option make the times on the files change to when the rsync was run? I see you have added the z option to compress the files. I would prefer to not compress the files as in doing so would defeat the PnP ability of the backup I was making. I have sufficient disk space for the backup and so will use it. With the current switch configuration, if the the situation should arise that I need to restore the backup by switching the source and dest labels, I see there is no switch to decompress the file on returning it to its 'original' location. I'll cover the restoration of an rsync cp in a new thread. Tnx for the extra input -- ======================================================================== Hylton Conacher - Linux user # 229959 at http://counter.li.org Currently using SuSE 9.2 Professional with KDE ========================================================================
participants (5)
-
Carl William Spitzer IV
-
Dave Howorth
-
Hylton Conacher(ZR1HPC)
-
Jim Cunning
-
Ken Schneider