简体   繁体   中英

how to copy current date files or particular date files in linux using rsync command?

I new to linux, How to current date file copy from source folder to another location using by rsync command,

I Tried:

rsync -avzhe ssh root@192.168.0.100:/var/www/ /home/backup/

Here i copied all files and second time i did copy this increamental file only here, But I need only date wise file copy from source folder, How can i get this file date wise?

I found by find command using date wise, But I need rsync command... How can i copy files date wise or current date, any one help ...

thanks advance...

You can use an include filter to include filenames containing a date and exclude everything else. For example:

rsync --include='*20131029*' --exclude='*' -avz user@host:src dest

If you want to get files based on modification time, you can use find to generate a file list and then pass the list to rsync :

ssh user@host "find src -type f -mtime -1" > /tmp/filesToCopy
rsync --files-from=/tmp/filesToCopy -avz user@host:src dest
rm /tmp/filesToCopy 

Firstly you have to copy the file/folder date wise

cp -r source_file target_file_$(date +%F)

then you have to rsync the data

rsync -avzhe ssh root@192.168.0.100:/var/www/ /home/backup/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM