2

After spending time trying to make rsync work, I decided to use something else. I have a tree of files at /home that I want to backup to a 64G USB stick once a day, using the same tree structure, but only copy over the ones that don't exist in destination ( and preserve timestamps ).

The problem:

Even if a source folder has only one new file (and 400 old ones), my rsync always finds a reason to copy about half of them over to dest.

I experimented with something along the lines of this

find /home/me/a/r/z/ -type f -mmin 400 | xargs -0 -I{} cp '{}' /media/usb-id/$( cut -d / -f 4- {} )

Lots of mistakes, I know. I use "4" with cut because that's where the tree starts in destination (/media/usb-id/r/z/whatever). I think I should be using sed somehow in all of this. Any ideas?

Obvious error:

cut: {}: No such file or directory
pLumo
  • 27,991

2 Answers2

0

sudo rsync -Havn between ext4 file systems

is the best way to go, if you want to preserve permissions and ownership of the files. This can be very important, because the linux system depends on it. But it is not important for personal data files.

I would recommend to start with a 'dry run'

sudo rsync -Havn source/ target

and if it looks good, remove the option n and do it,

sudo rsync -Hav source/ target

It preserves 'everything', so you can copy a whole linux operating system from one ext4 file system to another ext4 file system. And you can copy only a limited directory tree that way too.


An alternative to ext4 on the target drive is udf, if you must be able to read it from Windows. See this link. The udf file system can manage the ownership and permissions (and time stamps) of linux file systems.

But there is a drawback with udf. There is no well known tool to repair it.

sudodus
  • 47,684
0

You might have a look at this: https://github.com/Fitus/Zaloha.sh. It is a find-based shell script, also based on the same idea as yours (but it is a little bit more complex than your one-liner, as you might expect) ...

Petas
  • 1