Page 2 of 3
Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]
Posted: 12. Sep 2010, 20:45
by thenktor
And of course you have to exclude /media, too

Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]
Posted: 12. Sep 2010, 20:59
by Dennola4
Oh yeah, good point.
Code: Select all
rsync -avx --exclude=/dev --exclude=/proc --exclude=/media / /media/disk
Thanks!

Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]
Posted: 13. Sep 2010, 08:14
by JRD
As an addition to this thread, I can also advice the use of the alternate software: backintime
As also an alternate method, why not using software RAID in mirror?
Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]
Posted: 13. Sep 2010, 08:49
by thenktor
JRD wrote:why not using software RAID in mirror?
Because RAID is not a backup

If I accidentally delete some files they are gone on my RAID but not on a backup.
Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]
Posted: 13. Sep 2010, 12:00
by JRD
you're right. I just don't know the reason of the poster whereas he searched for a backup solution or a redondance solution.
Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]
Posted: 13. Sep 2010, 14:58
by Dennola4
I looked at backintime, but since Slackware already comes with rsync, and since rsync is capable of doing what I need, the only obstacle would be my own ignorance. Therefore, time to learn rsync.
I actually have two more questions. Sorry, but I
really want to understand what I'm doing rather than just copying and pasting code.
1) I notice that in the rsync line you offered....
Code: Select all
rsync -avx --exclude=/dev --exclude=/proc / /media/disk
....
/media/disk doesn't end with a trailing backslash, like this:
/media/disk/ and I am wondering why not.
2) As you know, /home/dennis is on a separate partition. So when I mirror that sda partition to the corresponding sdb partition , do I use the same type of rsync line? In other words, would I run:
Code: Select all
rsync -avx /home/dennis /media/disk-1/dennis
....OR:
Code: Select all
rsync -avx /home/dennis/ /media/disk-1/dennis/
...OR none of the above?? Thanks for your patience in answering these questions.

Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]
Posted: 13. Sep 2010, 15:26
by Shador
It doesn't matter, unless for some very poorly written programs scripts maybe. But then they usually do something like this "/some/path" + "file" = "/some/pathfile" instead of doing "/some/path" + "/file".
In the first form /some/path may be a directory or a file.
In the second form /some/path/ must be a file.
Try this (best run it in a separate, empty directory):
Code: Select all
set -x
echo "blob" > blub
cat blub
cat blub/
rm blub
mkdir blub
touch blub/dennola
ln -s blub blob
ls -l blob
ls -l blob/
ls -l ./blob/../blub/..////blob
rm blob
rm -r blub
set +x
So for directories it doesn't matter whether there's a leading slash or not but for files it does and for symlinks/soft links too.
I can even build crazy paths like that last ls command and can use as many slashes as I want.
Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]
Posted: 13. Sep 2010, 19:48
by thenktor
Shador: I have to correct you here

For rsync the trailing slashes are
very important on the source dir.
rsync -av /home /backup creates a folder home inside of /backup.
rsync -av /home/ /backup syncs the content of home directly to /backup.
These 2 commands do the same:
rsync -av /src/foo /dest
rsync -av /src/foo/ /dest/foo
EDIT:
rsync -avx /home/dennis /media/disk-1/dennis would result in a dir structure /media/disk-1/dennis/dennis
rsync -avx /home/dennis/ /media/disk-1/dennis/ is OK. The trailing slash on the destination directory is not needed but does not harm.
Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]
Posted: 13. Sep 2010, 20:28
by Dennola4
Ok thenktor. I think I've got it.
There's still one thing hurting my brain. In the command:
Code: Select all
rsync -avx --exclude=/dev --exclude=/proc --exclude=/media / /media/disk
the source actually IS a leading slash (being the character representation of the root directory). So are we to just understand that a trailing slash is implied?
I hope I don't seem obtuse, I just can't seem to get rsync syntax clear in my mind and I would rather not bork my back-up HDD because I was too timid to ask specific questions..
Thanks again.

Re: Use RSYNC to copy changes in sda to sdb -- [SOLVED]
Posted: 13. Sep 2010, 21:09
by thenktor
It's a leading and a trailing slash
