Skip to content

Commit e815c50

Browse files
ashbbruno-
authored andcommitted
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.
1 parent 5f5f9d8 commit e815c50

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
e.g. `vim -S Session1.vim`.
3131
- Enable restoring command arguments for inline strategies with `*` character.
3232
- Kill session "0" if it wasn't restored.
33+
- Add `@resurrect-delete-backup-after` option to specify how many days of
34+
backups to keep - default is 30.
3335

3436
### v2.4.0, 2015-02-23
3537
- add "tmux-test"

scripts/save.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,12 @@ dump_shell_history() {
269269
}
270270

271271
remove_old_backups() {
272-
# remove resurrect files older than 30 days, but keep at least 5 copies of backup.
272+
# remove resurrect files older than 30 days (default), but keep at least 5 copies of backup.
273+
local delete_after="$(get_tmux_option "$delete_backup_after_option" "$default_delete_backup_after")"
273274
local -a files
274275
files=($(ls -t $(resurrect_dir)/${RESURRECT_FILE_PREFIX}_*.${RESURRECT_FILE_EXTENSION} | tail -n +6))
275276
[[ ${#files[@]} -eq 0 ]] ||
276-
find "${files[@]}" -type f -mtime +30 -exec rm -v "{}" \;
277+
find "${files[@]}" -type f -mtime "+${delete_after}" -exec rm -v "{}" \;
277278
}
278279

279280
save_all() {

scripts/variables.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ overwrite_option="@resurrect-never-overwrite"
4646

4747
# Hooks are set via ${hook_prefix}${name}, i.e. "@resurrect-hook-post-save-all"
4848
hook_prefix="@resurrect-hook-"
49+
50+
delete_backup_after_option="@resurrect-delete-backup-after"
51+
default_delete_backup_after="30" # days

0 commit comments

Comments
 (0)