Unverified Commit e815c50f authored by Ash Berlin-Taylor's avatar Ash Berlin-Taylor Committed by Bruno Sutic
Browse files

Make backup retention period configurable

For instance `tmux set-option -g @resurrect-delete-backup-after 1`
to only keep 1 day of backups.

Closes 252.
parent 5f5f9d8f
......@@ -30,6 +30,8 @@
e.g. `vim -S Session1.vim`.
- Enable restoring command arguments for inline strategies with `*` character.
- Kill session "0" if it wasn't restored.
- Add `@resurrect-delete-backup-after` option to specify how many days of
backups to keep - default is 30.
### v2.4.0, 2015-02-23
- add "tmux-test"
......
......@@ -269,11 +269,12 @@ dump_shell_history() {
}
remove_old_backups() {
# remove resurrect files older than 30 days, but keep at least 5 copies of backup.
# remove resurrect files older than 30 days (default), but keep at least 5 copies of backup.
local delete_after="$(get_tmux_option "$delete_backup_after_option" "$default_delete_backup_after")"
local -a files
files=($(ls -t $(resurrect_dir)/${RESURRECT_FILE_PREFIX}_*.${RESURRECT_FILE_EXTENSION} | tail -n +6))
[[ ${#files[@]} -eq 0 ]] ||
find "${files[@]}" -type f -mtime +30 -exec rm -v "{}" \;
find "${files[@]}" -type f -mtime "+${delete_after}" -exec rm -v "{}" \;
}
save_all() {
......
......@@ -46,3 +46,6 @@ overwrite_option="@resurrect-never-overwrite"
# Hooks are set via ${hook_prefix}${name}, i.e. "@resurrect-hook-post-save-all"
hook_prefix="@resurrect-hook-"
delete_backup_after_option="@resurrect-delete-backup-after"
default_delete_backup_after="30" # days
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment