With a source disk containing x-amount of space, and a backup disk containing
y-amount of space, where x > y, to back up files from x, newest first, until
disk y is full, it's as simple as a bash-loop where you specify date ranges on
each iteration:
for days in {1..30}; do
find source/ -type f -mtime -${days} -exec rsync --archive '{}' target/'{}' \;
done
- or -
for days in {0..30}; do
find source/ -type f \( -mtime +${days} -mtime -$(($days + 1)) \) -exec tar cf
- '{}' + |
tar xvf - -C target/
# and use '--strip-components n' to remove leading paths on target
done
There are advantages and disadvantages to each.
> ----------------------------------------
> From: Andrea Venturoli <[email protected]>
> Sent: Wed Apr 27 09:47:40 CEST 2022
> To: <[email protected]>
> Subject: Fill a disk with more recent files
>
>
>
> Hello.
>
> Suppose I have a large storage of files and a smaller disk (backup).
> I need to copy as much as I can from source to target and I want the
> most recent files.
>
> Before I start scripting and reinvent the wheel, is there some tool already?
>
> bye & Thanks
> av.
>
--
Sent with https://mailfence.com
Secure and private email