If I have a backup script that does the following: (latest 2.6.9 rsync) rsync --archive --hard-links --force --ignore-errors --numeric-ids --keep-dirlinks --delete / /backup I've found that if there is a symlink in place that gets backed up (which goes fine), i.e.: homelink -> /home/ and then that symlink gets changed into an actual directory, i.e.: rm homelink mkdir homelink rsync will actually delete everything in the directory that the symlink pointed to (in the above case it deletes /home). Is the workaround to use --delete-after to avoid this behavior, or is my logic flawed in using rsync with the command above to produce a mirror copy of an entire server to a backup drive? Thanks. Rob
On Mon, 2007-10-29 at 13:15 -0400, rob@mangiafico.net wrote:> If I have a backup script that does the following: > (latest 2.6.9 rsync) > > rsync --archive --hard-links --force --ignore-errors --numeric-ids > --keep-dirlinks --delete / /backup > > I've found that if there is a symlink in place that gets backed up (which > goes fine), i.e.: > homelink -> /home/ > > and then that symlink gets changed into an actual directory, i.e.: > rm homelink > mkdir homelinkI assume this directory is empty?> rsync will actually delete everything in the directory that the symlink > pointed to (in the above case it deletes /home).Rsync's behavior, however surprising, is correct. Since you passed --keep-dirlinks, rsync is mapping the source's "homelink" directory to the target directory of the destination's "homelink" symlink, i.e., /home. (Without --keep-dirlinks, rsync would first replace the destination's "homelink" with an actual directory.) Since you passed --delete, rsync deletes any and all files from /home that lack counterparts in the source's "homelink".> Is the workaround to use --delete-after to avoid this behavior, or is my > logic flawed in using rsync with the command above to produce a mirror > copy of an entire server to a backup drive?--delete-after gives the same behavior. To stop rsync from following the destination's symlink to /home, you will have to remove --keep-dirlinks. Unfortunately, if there are other dirlinks that you *do* need to keep, you will have to do something more complicated. Matt
On Tue, 30 Oct 2007, Matt McCutchen wrote:> On Mon, 2007-10-29 at 13:15 -0400, rob@mangiafico.net wrote: > > If I have a backup script that does the following: > > (latest 2.6.9 rsync) > > > > rsync --archive --hard-links --force --ignore-errors --numeric-ids > > --keep-dirlinks --delete / /backup > > > > I've found that if there is a symlink in place that gets backed up(which> > goes fine), i.e.: > > homelink -> /home/ > > > > and then that symlink gets changed into an actual directory, i.e.: > > rm homelink > > mkdir homelink > > I assume this directory is empty?Yes.> > rsync will actually delete everything in the directory that thesymlink> > pointed to (in the above case it deletes /home). > > Rsync's behavior, however surprising, is correct. Since you passed > --keep-dirlinks, rsync is mapping the source's "homelink" directory to > the target directory of the destination's "homelink" symlink, > i.e., /home. (Without --keep-dirlinks, rsync would first replace the > destination's "homelink" with an actual directory.) Since you passed > --delete, rsync deletes any and all files from /home that lack > counterparts in the source's "homelink". > > > Is the workaround to use --delete-after to avoid this behavior, or ismy> > logic flawed in using rsync with the command above to produce a mirror > > copy of an entire server to a backup drive? > > --delete-after gives the same behavior. To stop rsync from following > the destination's symlink to /home, you will have to remove > --keep-dirlinks. Unfortunately, if there are other dirlinks that you > *do* need to keep, you will have to do something more complicated.Thanks for the explanation. Since all we're doing is using rsync to make a backup on a second drive, and this backup will be used for either file/directory restores, or in the event of a primary drive failure, used in a bare metal restore situation, I believe leaving off "--keep-dirlinks" will not cause any problems, as the symlinks that point to directories on the primary drive will still be intact on the backup drive, and can be restored "as is" on a restore, correct? We don't need rsync to follow the symlink, as we're already backing up all the data on the OS. Rob
Maybe Matching Threads
- --keep-dirlinks --delete erroneously deletes symlinks to directories
- Using --keep-dirlinks : recursive symlinks problem
- symlink in -R src_dirlist and real dirs on target
- rsync replacing symlinks without warning (resend)
- rsync replacing symlinks without warning (resend)