Results 1 to 6 of 6

Thread: rsync --delete doen not delete some things

  1. #1

    Default rsync --delete doen not delete some things

    I'm cloning a system to a virtual machine. The source system has a ext4 / partition with almost everything (except /boot).
    The target VM has some partitions, I have booted it with a Live CD, mounted all of them on a /tutatis directory

    Code:
    /dev/sda1 on /tutatis type btrfs (rw,relatime,space_cache,subvolid=257,subvol=/@)
    /dev/sda1 on /tutatis/var type btrfs (rw,relatime,space_cache,subvolid=258,subvol=/@/var)
    /dev/sda1 on /tutatis/boot/grub2/i386-pc type btrfs (rw,relatime,space_cache,subvolid=259,subvol=/@/boot/grub2/i386-pc)
    /dev/sda1 on /tutatis/boot/grub2/x86_64-efi type btrfs (rw,relatime,space_cache,subvolid=260,subvol=/@/boot/grub2/x86_64-efi)
    /dev/sda1 on /tutatis/opt type btrfs (rw,relatime,space_cache,subvolid=261,subvol=/@/opt)
    /dev/sda1 on /tutatis/srv type btrfs (rw,relatime,space_cache,subvolid=262,subvol=/@/srv)
    /dev/sda1 on /tutatis/tmp type btrfs (rw,relatime,space_cache,subvolid=263,subvol=/@/tmp)
    /dev/sda1 on /tutatis/usr/local type btrfs (rw,relatime,space_cache,subvolid=264,subvol=/@/usr/local)
    /dev/sda1 on /tutatis/software type btrfs (rw,relatime,space_cache,subvolid=265,subvol=/@/software)
    /dev/sdb1 on /tutatis/home type ext4 (rw,relatime)
    /dev/sdc1 on /tutatis/imagenes type ext4 (rw,relatime)

    And then I have enabled rsyncd and run rsync from the source:
    Code:
    tutatis:~ # rsync  -aAxXHu --times --delete -v --log-file=rsync.log / 192.168.2.163::root

    I ran it and it seems to work (it copied over 1TB and all seemed to be in order), then I realized I have some junk directories in the source, I delete them and run again rsync (same command), new stuff was copied, but the junk directories were not deleted.

    I think --delete should have deleted them .... what am I doing wrong?


    best regards

  2. #2

    Default Re: rsync --delete doen not delete some things

    Try without the -u Update option "Skip files that are newer on the receiver". A file existing is newer than a file not-existing (since not-existing is nothing) and rsync probably skips them from the --delete option.

    You can also remove the --times option since it is automatically a part of the -a "Archive" option.

  3. #3

    Default Re: rsync --delete doen not delete some things

    Quote Originally Posted by 8876523450 View Post
    Try without the -u Update option "Skip files that are newer on the receiver". A file existing is newer than a file not-existing (since not-existing is nothing) and rsync probably skips them from the --delete option.

    You can also remove the --times option since it is automatically a part of the -a "Archive" option.
    I did, but after doing it
    Code:
    rsync  -aAxXhH --delete -v --log-file=rsync.log / 192.168.2.163::root
    on the source
    Code:
    tutatis:~ # tree -ah /
    .....
    289565 directories, 2047732 files

    on the target
    Code:
    [root@sysrescue ~]# tree -ah /tutatis
    .....
    254719 directories, 1773403 files

    and the directories that should be delete are still there

  4. #4

    Default Re: rsync --delete doen not delete some things

    The -H Preserve Hard Links option could also be the problem. Obviously, with that option, if that data is referenced by anything else in the system, it won't get deleted. I don't think you don't need to preserve hard links since you're copying to an entirely separate system.

    I suggest keeping it simple with just using -av --delete and fine-tune from there.

    Add --dry-run while experimenting so rsync only outputs what it would have done until you're confident you have it working.

  5. #5

    Default Re: rsync --delete doen not delete some things

    After a lot of tests I have discover what was the problem.
    I have two different filesystems in the source ( / and /boot) and three in the target ( / and btrfs subvols, /home and /imagenes ).
    I was using
    Code:
    rsync  -aAxXhH --delete -v  / 192.168.2.163::root/
    rsync  -aAxXhH --delete -v  /boot/ 192.168.2.163::root/boot/
    any other filesystem (
    with "x" option (not jump to another filesystem) in order to copy both filesystems from the source to the target avoiding problems with any other filesystem like /dev, /run .etc.

    I didn't that the "x" option would affect also the target, but it does. In the source /home is included in the / filesystem, but in the target is a separate filesystem, so I had to run

    Code:
    rsync  -aAxXhH --delete -v  / 192.168.2.163::root/
    rsync  -aAxXhH --delete -v  /boot/ 192.168.2.163::root/boot/
    rsync  -aAxXhH --delete -v  /home/ 192.168.2.163::root/home/
    rsync  -aAxXhH --delete -v  /imagenes/ 192.168.2.163::root/imagenes/

    Now it seems everything is synced

    best regards

  6. #6

    Default Re: rsync --delete doen not delete some things

    Quote Originally Posted by 8876523450 View Post
    Try without the -u Update option "Skip files that are newer on the receiver". A file existing is newer than a file not-existing (since not-existing is nothing) and rsync probably skips them from the --delete option.

    You can also remove the --times option since it is automatically a part of the -a "Archive" option.
    I don't think -u has any affect. Here's my backup script with different -u and -v options, and they all delete the same number of files:
    Code:
    > sudo rsync -vnaRsu --delete --info=del1,stats1,name1 --exclude=/root/.cache --exclude=/home/*/{.cache,.local/share/libvirt/images,.mozilla,.xsession-errors*,.config/chromium,.config/discord,.config/ibus,.config/pipewire/media-session.d,.sword/InstallMgr,.zoom/logs,.Xauthority} /etc /root /usr/etc /usr/local/bin /home/gene /mnt/backups/openSUSE | grep '^deleting' | wc -l
    1672
    
    > sudo rsync -naRsu --delete --info=del1,stats1,name1 --exclude=/root/.cache --exclude=/home/*/{.cache,.local/share/libvirt/images,.mozilla,.xsession-errors*,.config/chromium,.config/discord,.config/ibus,.config/pipewire/media-session.d,.sword/InstallMgr,.zoom/logs,.Xauthority} /etc /root /usr/etc /usr/local/bin /home/gene /mnt/backups/openSUSE | grep '^deleting' | wc -l
    1672
    
    > sudo rsync -naRs --delete --info=del1,stats1,name1 --exclude=/root/.cache --exclude=/home/*/{.cache,.local/share/libvirt/images,.mozilla,.xsession-errors*,.config/chromium,.config/discord,.config/ibus,.config/pipewire/media-session.d,.sword/InstallMgr,.zoom/logs,.Xauthority} /etc /root /usr/etc /usr/local/bin /home/gene /mnt/backups/openSUSE | grep '^deleting' | wc -l
    1672
    I don't specify --delete on a regular basis, so there are quite a few orphaned files.

    Gene

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •