You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's an example of how you could do this in bash. The below code sorts a list of archive names that are older than a cutoff time, and creates a command to delete them. This could be changed to work with filenames.
Another option would be to use find to look for files created before a certain day. However, the create date could be misleading.
cutoff_date="backup-$(/bin/date -u --iso-8601=seconds -d '-3 months')"
archives="$(/usr/bin/tarsnap --list-archives | /usr/bin/sort)"
cutoff_archives=""
cutoff_command="/usr/bin/tarsnap --humanize-numbers -d"
while IFS=' ' read -r archive; do
cutoff_archive=$(echo -e "${cutoff_date}\n${archive}" \
| /usr/bin/sort \
| /usr/bin/head -n 1 \
| /bin/grep -v -F "$cutoff_date" || true)
if [ -z "$cutoff_archive" ]; then
continue
fi
if [ -z "$cutoff_archives" ]; then
cutoff_archives="${cutoff_archive}"
else
cutoff_archives="${cutoff_archives}\n${cutoff_archive}"
fi
cutoff_command="${cutoff_command} -f ${cutoff_archive}"
done <<< "$archives"
Here's an example of how you could do this in bash. The below code sorts a list of archive names that are older than a cutoff time, and creates a command to delete them. This could be changed to work with filenames.
Another option would be to use
find
to look for files created before a certain day. However, the create date could be misleading.Originally posted by @auspicacious in https://github.com/Safecast/safecastapi/pull/699/files
The text was updated successfully, but these errors were encountered: