0

I've been thinking about how I could copy files that are 0-30 days old with different file types with rsync, find and mtime.

Thefind syntax below works, but I do not get it to work with rsync.

rsync \ --files-from=<(find . -type f \( -name "*.X" -or -name "*.x1" \) -mtime -30) [email protected]:/where/to/put/files
3
  • Please explain the meaning of "no success". What precisely happens or doesn't happen? Are any files transferred or are none? What output does rsync generate? What error messages do you see?
    – John1024
    Sep 23, 2019 at 21:02
  • Hello, and welcome to Unix & Linux. Two quick clarifications that I think would help getting a good answer: (1) Is the backslash between rsync and --files-from a copy/paste error? Second, what does "no success" mean — do you get an error message? Does it just not copy the files? Please edit your question to include these details.
    – derobert
    Sep 23, 2019 at 21:02
  • Hi there! Sorry for bad explanation, what I mean is that I dont get it to work. When it comes to the rsync syntax im confused if Im supposed to use the \ or not
    – anon
    Sep 23, 2019 at 21:05

1 Answer 1

0

It works if you use add a SRC argument (the . as source directory):

rsync --files-from=<(find . -type f \( -name "*.X" -o -name "*.x1" \) -mtime -30) . [email protected]:/where/to/put/files
7
  • Hi @Freddy Thanks, we are getting closer to make it work. When I run it now i get the following: rsync: change_dir “/my/dir/that/has/a/name//\#342\#200\#224files-from=/dev/fd" failed: No such file or directory (2) skipping directory . rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1052) [sender=3.0.9] -But when I run the find syntax in the same directory I find all of them which i want to copy
    – anon
    Sep 23, 2019 at 21:23
  • I had a mistake in my answer. If you copied this example, make sure --files-from starts with two minus characters --. Hope this fixes the error.
    – Freddy
    Sep 23, 2019 at 21:34
  • No problem Freddy. Still no luck. [email protected]’s password: rsync: change_dir “/xx/xx/xx//\#342\#200\#224files-from=/dev/fd" failed: No such file or directory (2) skipping directory . rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1052) [sender=3.0.9]
    – anon
    Sep 23, 2019 at 21:38
  • Hmm. Does your target directory exist? If your target dir is /a/b/c, then at least /a/b should exist.
    – Freddy
    Sep 23, 2019 at 21:43
  • Yes it does, it was just a typo from me.. Now I get: rsync: mkstemp "/aa/bb/cc/.my.file failed: Permission denied (13)
    – anon
    Sep 24, 2019 at 17:39

You must log in to answer this question.