Hi, I use rsync with such options: OPTIONS="-a -u -z -v -S --delete-during --ignore-errors \ -b --backup-dir=${PATH_BACKUP}/${DATE_YESTERDAY} \ --exclude-from=$IGNORE" rsync $OPTIONS ${PATH_SRC} \ ${PATH_BACKUP}/current Everything works as it should be, deleted files are transfered everyday to a new catalog, determinated by a variable ${DATE_YESTERDAY}. But if an empty dir is deleted from ${PATH_SRC}, then it is accordingly deleted from ${PATH_BACKUP}/current, and don`t appear in ${PATH_BACKUP}/${DATE_YESTERDAY}. Do you know what to do it to make empty dirs be transferred to ${PATH_BACKUP}/${DATE_YESTERDAY}? -- BRGDS. Mark
On Mon, Apr 30, 2007 at 07:17:52PM +0400, Mark wrote:> Hi, > > I use rsync with such options: > > OPTIONS="-a -u -z -v -S --delete-during --ignore-errors \ > -b --backup-dir=${PATH_BACKUP}/${DATE_YESTERDAY} \ > --exclude-from=$IGNORE"[skip]> > Do you know what to do it to make empty dirs be transferred > to ${PATH_BACKUP}/${DATE_YESTERDAY}?All the written above in actual work: # ls -l total 0 drwxr-xr-x 2 root root 48 May 1 23:07 backup drwxr-xr-x 5 root root 192 May 1 23:08 test # ls -l test/ total 0 drwxr-xr-x 2 root root 48 May 1 23:08 dir1 drwxr-xr-x 2 root root 48 May 1 23:08 dir2 drwxr-xr-x 2 root root 48 May 1 23:08 dir3 -rw-r--r-- 1 root root 0 May 1 23:08 file1 -rw-r--r-- 1 root root 0 May 1 23:08 file2 -rw-r--r-- 1 root root 0 May 1 23:08 file3 # ls -l backup/ total 0 # rsync -a -z -v -S --delete-during -b --backup-dir=/full_path_to/backup/`date -d '1 day ago' +%Y-%m-%d` ./test/ ./backup/current building file list ... done created directory ./backup/current ./ file1 file2 file3 dir1/ dir2/ dir3/ sent 266 bytes received 110 bytes 752.00 bytes/sec total size is 0 speedup is 0.00 # ls -l backup/current/ total 0 drwxr-xr-x 2 root root 48 May 1 23:08 dir1 drwxr-xr-x 2 root root 48 May 1 23:08 dir2 drwxr-xr-x 2 root root 48 May 1 23:08 dir3 -rw-r--r-- 1 root root 0 May 1 23:16 file1 -rw-r--r-- 1 root root 0 May 1 23:08 file2 -rw-r--r-- 1 root root 0 May 1 23:08 file3 # rm test/file1 # rsync -a -z -v -S --delete-during -b --backup-dir=/full_path_to/backup/`date -d '1 day ago' +%Y-%m-%d` ./test/ ./backup/current building file list ... done ./ deleting file1 sent 119 bytes received 26 bytes 290.00 bytes/sec total size is 0 speedup is 0.00 # ls -l backup/current/ total 0 drwxr-xr-x 2 root root 48 May 1 23:08 dir1 drwxr-xr-x 2 root root 48 May 1 23:08 dir2 drwxr-xr-x 2 root root 48 May 1 23:08 dir3 -rw-r--r-- 1 root root 0 May 1 23:08 file2 -rw-r--r-- 1 root root 0 May 1 23:08 file3 # ls -l backup/2007-04-30/ total 0 -rw-r--r-- 1 root root 0 May 1 23:18 file1 # rmdir test/dir1 # rsync -a -z -v -S --delete-during -b --backup-dir=/full_path_to/backup/`date -d '1 day ago' +%Y-%m-%d` ./test/ ./backup/current building file list ... done ./ deleting dir1/ sent 107 bytes received 26 bytes 266.00 bytes/sec total size is 0 speedup is 0.00 # ls -l test/ total 0 drwxr-xr-x 2 root root 48 May 1 23:08 dir2 drwxr-xr-x 2 root root 48 May 1 23:08 dir3 -rw-r--r-- 1 root root 0 May 1 23:08 file2 -rw-r--r-- 1 root root 0 May 1 23:08 file3 # ls -l backup/current/ total 0 drwxr-xr-x 2 root root 48 May 1 23:08 dir2 drwxr-xr-x 2 root root 48 May 1 23:08 dir3 -rw-r--r-- 1 root root 0 May 1 23:08 file2 -rw-r--r-- 1 root root 0 May 1 23:08 file3 # ls -l backup/2007-04-30/ total 0 -rw-r--r-- 1 root root 0 May 1 23:18 file1 In result the catalog "dir1" is lost. Why? -- BRGDS. Mark.
On Mon, Apr 30, 2007 at 07:17:52PM +0400, Mark wrote:> But if an empty dir is deleted from ${PATH_SRC}, then it is > accordingly deleted from ${PATH_BACKUP}/current, and don`t appear in > ${PATH_BACKUP}/${DATE_YESTERDAY}.That's correct. Dirs are not currently considered to be content that needs to be backed up, so they are only created in the backup area in order to store backup content. This may change in the future, or it may not -- I haven't decided yet. ..wayne..
On 4/30/07, Mark <rsync@renton.name> wrote:> Hi, > > I use rsync with such options: > > OPTIONS="-a -u -z -v -S --delete-during --ignore-errors \ > -b --backup-dir=${PATH_BACKUP}/${DATE_YESTERDAY} \ > --exclude-from=$IGNORE" > > rsync $OPTIONS ${PATH_SRC} \ > ${PATH_BACKUP}/current > > Everything works as it should be, deleted files are transfered everyday > to a new catalog, determinated by a variable ${DATE_YESTERDAY}. > > > But if an empty dir is deleted from ${PATH_SRC}, then it is > accordingly deleted from ${PATH_BACKUP}/current, and don`t appear in > ${PATH_BACKUP}/${DATE_YESTERDAY}. > > Do you know what to do it to make empty dirs be transferred > to ${PATH_BACKUP}/${DATE_YESTERDAY}?You could use an extra pass at the beginning to back up all dirs about to be deleted, whether they are empty or not: rsync -ni ${OPTIONS} ${PATH_SRC} ${PATH_BACKUP}/current \ | sed -rne 's#^\*deleting (.*)/$#\1#p' \ | rsync --out-format='backing up %n' --files-from=- \ ${OPTIONS} ${PATH_BACKUP}/current ${PATH_BACKUP}/${DATE_YESTERDAY} Matt