简体   繁体   中英

How to compress new files from folder and subfolder

I need to generate from time to time a backup only from the new files, that are distributed in folders and subfolders, created after a given datetime. Is there a way of doing this, using a tar command line or a shell bash (I don't have GUI interface installed)? The structure of the directories need to be maintened.

tar stores an entire directory tree by default. As to the date restriction: the man page of tar (run man tar in terminal) tells us there's an option for exactly that:

 -N, --newer, --after-date DATE-OR-FILE
       only store files newer than DATE-OR-FILE

The parameter is either a date or a file whose modification time will be used as a reference.

Example of using a date:

tar czf test.tar.gz -N '2014-10-30 12:34:56' MyDirectory

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