Skip to content
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

Modified the deletion to trim backups for each specific backup target. #28

Merged

Conversation

shortchanged13
Copy link
Contributor

This is my first ever commit/pull request. Please let me know what I can do better.

I see that you have already moved the backup type determination to inside the backup loop. I also made the change in this request. I didn't know how to base my changes off of your changes.

I have also put a loop around the backup deletion process. It will now look at the backups that have been done per backup target. Those two deletion sections could have been pushed into the backup target loop but I choose to wrap them separately since only one --list-archive would be needed.

Thank you for the script. Its quick, simple and gets the job done. Let me know if there is anything else you would like me to take a look at.

Scott

…ermine the backup type for each backup target. Also added the backup target name to the grep so the return list is limited to the specific backup target.

Added a loop around the cleanup of the backups.  I choose to put the existing routine inside a loop instead of adding it to the backup target loop so the call to --list-archives is only run once instead of after each backup target.  Also added the backup target name to the grep so the return list is limited to the specific backup target.
@alexjurkiewicz
Copy link
Owner

Thanks, and congrats on your first PR! I'll take a closer look tonight, but this feature is very exciting and will fix up (imho) the biggest wart of acts.

Copy link
Owner

@alexjurkiewicz alexjurkiewicz left a comment

Choose a reason for hiding this comment

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

Sorry for the delay. I think this is great! There are a few comments I have.

acts Outdated
echo "$archives" | grep -E "^$archiveprefixtodel" | while read -r archivetodel; do
log_debug "message=\"Deleting backup $archivetodel\""
$tarsnap -d -f "$archivetodel"

Copy link
Owner

Choose a reason for hiding this comment

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

extra newline

acts Outdated
@@ -161,6 +146,20 @@ backuprc=0 # Notice any failed backups
for dir in $backuptargets; do
archive_starttime=$(date +%s)
nicedirname=$(echo "$dir" | tr -d '/')
# Determine the archive type to create
if echo "$archives" | grep -E -q "^$hostname-yearly-$year-.+-$nicedirname"; then
Copy link
Owner

Choose a reason for hiding this comment

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

The pattern (and all others that now have .+ in the middle should end with \$, just to be safe.

acts Show resolved Hide resolved
acts Show resolved Hide resolved
@shortchanged13
Copy link
Contributor Author

shortchanged13 commented Feb 7, 2019 via email

@alexjurkiewicz
Copy link
Owner

You can push more commits to the branch you've opened this PR from, and they will automatically show up in the PR!

For future reference, please use the github UI to respond to PR reviews, you can thread the conversations that way. But it's no big deal here because the review is quite small.

The only difference between the last two comments is what the log message would say. I was imagining something like:
log_debug "message=\"Backing up $dir\""
and (like you suggested):
log_debug "message=\"Checking $dir for old backups to delete\""

Added '$' to the end of the grep statements to enhance safety

Removed extra blank line
@shortchanged13
Copy link
Contributor Author

Requested changes have been made and pushed. Thanks for clarification on the debug messages. I didn't realize it was two different loops.

Copy link
Owner

@alexjurkiewicz alexjurkiewicz left a comment

Choose a reason for hiding this comment

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

Looks good!

@alexjurkiewicz
Copy link
Owner

I think this is ready to merge! I don't currently use acts so I can't test it myself -- have you been running this for a few days? Does adding new backup paths work properly?

@alexjurkiewicz
Copy link
Owner

alexjurkiewicz commented Feb 11, 2019

One other thought: can you please update the README to mention that if you remove a backup target, you'll have to delete its old backups by hand?

@alexjurkiewicz alexjurkiewicz merged commit fb0a7af into alexjurkiewicz:master Feb 12, 2019
@alexjurkiewicz
Copy link
Owner

Thanks for the contribution! It's merged, and acts is now v1.4b1

@shortchanged13
Copy link
Contributor Author

Thank you. I missed your messages. I have had it running daily.

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

Successfully merging this pull request may close these issues.

None yet

2 participants