Skip to content

auto remove old backup files #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

auto remove old backup files #151

wants to merge 1 commit into from

Conversation

xu-cheng
Copy link
Contributor

remove backup files older than 30 days, but keep at least 5 copies of backup.

Fixes #102.

@xu-cheng
Copy link
Contributor Author

Ping @bruno-

@reenberg
Copy link

I would also wary much like this to be merged in.

@Kriechi
Copy link

Kriechi commented Aug 14, 2016

Does tail -n +5 work on OSX too? This usually behaves a bit different due to BSD/GNU weirdness.

@xu-cheng
Copy link
Contributor Author

Does tail -n +5 work on OSX too?

Yes.

Updated a bit to handle when there is less 5 files. Any chance to review this and maybe merge it? Thanks.

@czchen
Copy link

czchen commented Apr 15, 2017

Hi @bruno- ,

Any update for this PR?

scripts/save.sh Outdated
# remove backup files older than 30 days, but keep at least 5 copies of backup.
local -a files
pushd "$(resurrect_dir)" >/dev/null
files=($(ls -t ./*.txt | tail -n +6))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any benefit of using pushd + popd over just ls -t $(resurrect_dir)/*.txt

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use ls -t $(resurrect_dir)/*.txt

remove backup files older than 30 days, but keep at least 5 copies of backup.

Fixes #102.
@bruno-
Copy link
Member

bruno- commented Jun 3, 2017

Hi,
thank you for the contribution. This is merged locally so closing this PR.

When I tested this on a mac I found the find -delete option doesn't work. The problem symptoms are described here.
To get around this I changed the delete command to use find ... | xargs rm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants