You are not logged in.

#1 2018-02-03 13:52:19

daankata
Member
Registered: 2017-05-21
Posts: 47

Copy the content of a directory with rsync

I am trying to restore a backup of my boot partition with rsync. So I sync my external media with my boot directory, but everytime rsync creates another directory in my boot directory and it doesn't sync with the existing files but simply copies the folder, i.e.:

rsync -aAX --delete /mnt/backup/boot /boot

After executing the command, rsync doesn't sync "/mnt/backup/boot/initramfs-linux.img" with the "/boot/initramfs-linux.img" but creates a "/boot/boot/initramfs-linux.img".
How can I prevent the creating of "/boot/boot" with rsync? I tried:

rsync -aAX --delete /mnt/backup/boot/* /boot

But it said:

rsync: link_stat "/mnt/backup/boot/*" failed: No such file or directory (2)

Thank you!

Last edited by daankata (2018-02-03 13:54:27)

Offline

#2 2018-02-03 14:01:09

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: Copy the content of a directory with rsync

The trailing / is important for sync targets....
/mnt/backup/boot will copy the literal "boot" to whatever you told it whereas /mnt/backup/boot/ will copy the CONTENTS of "boot" not the directory itself.

What is the output of `ls -l /mnt/backup/boot`


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#3 2018-02-03 14:09:13

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: Copy the content of a directory with rsync

While I love rsync for all the cool things it can do, you aren't doing any of those cool things.  Just use `cp -a`.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2018-02-03 14:46:26

daankata
Member
Registered: 2017-05-21
Posts: 47

Re: Copy the content of a directory with rsync

graysky wrote:

The trailing / is important for sync targets....
/mnt/backup/boot will copy the literal "boot" to whatever you told it whereas /mnt/backup/boot/ will copy the CONTENTS of "boot" not the directory itself.

What is the output of `ls -l /mnt/backup/boot`

/mnt/backup/boot contains the exactly the same things as /boot does:

grub
initramfs-linux-fallback.img
initramfs-linux.img
initramfs-linux-lts-fallback.img
initramfs-linux-lts.img
intel-ucode.img
vmlinuz-linux
vmlinuz-linux-lts

But when syncing with rsync, /boot `ls -l` output is:

boot
grub
initramfs-linux-fallback.img
initramfs-linux.img
initramfs-linux-lts-fallback.img
initramfs-linux-lts.img
intel-ucode.img
vmlinuz-linux
vmlinuz-linux-lts

Where nothing has updated except /boot/boot was created.
Also adding the trailing slash doesn't copy anything.

rsync -aAX --delete /mnt/backup/boot/ /boot

Note: The content of the files of the source and /boot are different.
Thank you!

Last edited by daankata (2018-02-03 14:48:01)

Offline

#5 2018-02-03 14:50:50

daankata
Member
Registered: 2017-05-21
Posts: 47

Re: Copy the content of a directory with rsync

Trilby wrote:

While I love rsync for all the cool things it can do, you aren't doing any of those cool things.  Just use `cp -a`.

If there isn't a way with rsync I will probably use `cp -a`, but I do not want everytime to copy the contents to /boot, but simply sync it. Is there a way to achieve this?
Thank you!

Last edited by daankata (2018-02-03 14:51:40)

Offline

Board footer

Powered by FluxBB