On 01/12/2018 12:16 PM, jdd@dodin.org wrote:
Le 12/01/2018 à 00:46, Bernhard Voelker a écrit :
So you could use that to move all those files into a 2012 folder (untested!):
$ find . -type f -newermt 2012-01-01 ! -newermt 2013-01-01 -print0 \ | rsync -HAXaxi --from0 --files-from=- . /path2/archive-2012/.
It's nearly what I expected, thanks.
I use the (mounted) path of the sd card as destination, works as root (to preserve permissions) and can omit the first -newer for a simple "from date". Use of ! on the second newer is very smart.
however, I don't fully understand how it works.
you can set up a test directory hierarchy: $ mkdir -p src/a/b src/c $ touch -d 2012-06-06 src/file-from-2012 $ touch -d 2013-06-06 src/a/file-from-2013 $ touch -d 2014-06-06 src/a/b/file-from-2014 Now you have: $ find -type f -exec ls -log '{}' + -rw-r--r-- 1 0 Jun 6 2014 ./src/a/b/file-from-2014 -rw-r--r-- 1 0 Jun 6 2013 ./src/a/file-from-2013 -rw-r--r-- 1 0 Jun 6 2012 ./src/file-from-2012 Selecting with only -newermt for files newer than Jan 1st of 2013 gives also the file from 2014: $ find -type f -newermt 2013-01-01 -exec ls -log '{}' + -rw-r--r-- 1 0 Jun 6 2014 ./src/a/b/file-from-2014 -rw-r--r-- 1 0 Jun 6 2013 ./src/a/file-from-2013 Adding the "! -newermt" (spoken "not newer than") will find only the files from 2013: $ find -type f -newermt 2013-01-01 ! -newermt 2014-01-01 -exec ls -log '{}' + -rw-r--r-- 1 0 Jun 6 2013 ./src/a/file-from-2013
Specially I guess find send the file names one at a time, but do rsync take them one by one, copying them one at a time, or as a list, waiting to the list to be complete to begin writing.
yes, find passes the name of the files one-by-one to rsync, and that will start the sync as early the names are available on the pipe.
In other words, will the option --delete works?
NO, --delete is operating on the DESTINATION. As far as I understood you would like to remove all the archived files from the SOURCE, right? As mentioned in my previous mail, I'd save the output of find in a file, and then pass that file a) to rsync for archiving, and then b) to "xargs rm" to delete it in the SOURCE directory. 1. Get file names: $ find . -type f -newermt 2012-01-01 ! -newermt 2013-01-01 -print0 \ > list 2. Archive the files: $ rsync -HAXaxi --from0 --files-from=- . /path2/archive-2012/. \ < list 3. Remove the files from the SOURCE: $ xargs -0 rm -v < list
I'm also surprised to see the "dot", I was thinking of the files as source and if I get it well, file list is only a test on the "." source that need to be set.
Well, I didn't find a proper example with the --files-from option in the man page, so usin "." was just guesswork. ;-)
the "-i" output is not that easy to understand neither
you could change that to '-v' if you are more familiar with it.
anyway, I wouldn't have got that command line without help, thanks a lot!
no worries! Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org