trante
trante

Reputation: 34006

7zip archieving files that are newer than a specific date

I create 7zip files like this from command line in Linux:

#   7za   a   /backup/files.7z   /myfolder

After that I want to create another zip file that includes all files inside /myfolder that are newer then dd-mm-YY.
Is it possible to archieve files with respect to file's last change time ?

(I don't want to update "files.7z" file I need to create another zip file that includes only new files)

Upvotes: 1

Views: 5971

Answers (2)

ɹǝzıuıʇnɹɔs
ɹǝzıuıʇnɹɔs

Reputation: 9

The proposal by Gooseman:

# find myfolder -mtime -10 -exec 7za a /backup/newfile.7z {} \;

adds all files of each directory tree which got new files since the directory is also new and then adds all new files just archived again.

The following includes only new files but does not store the path names in the archive:

# find myfolder -type f -mtime -10 -exec 7za a /backup/newfile.7z {} \;

This stores only new files — with path names:

# find myfolder -type f -mtime -10 > /tmp/list.txt
# tar -cvf /tmp/newfile.tar -T /tmp/list.txt
# 7za a /backup/newfile.7z /tmp/newfile.tar

Upvotes: 1

Gooseman
Gooseman

Reputation: 2231

You could try this command:

find myfolder -mtime -10 -exec 7za a /backup/newfile.7z {} \;

In order to find the number to use by the mtime option you could use some of these answers: How to find the difference in days between two dates? In your case it would be the difference between the current date and your custom dd-mm-YY (in my example dd-mm-YY is 10 days back from now)

From man find:

-n for less than n

-mtime n

File's data was last modified n*24 hours ago. See the comments for -atime to understand how rounding affects the interpretation of file modification times.

Upvotes: 0

Related Questions