Skip to content

Commit

Permalink
Merge pull request #181 from booxter/backup
Browse files Browse the repository at this point in the history
Add backup script
  • Loading branch information
booxter authored Jan 8, 2025
2 parents f6f532c + 7eaf2c4 commit 867e3c7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.sqlite
backup/*
*.db
*/__pycache__/
*.pyc
Expand Down
19 changes: 19 additions & 0 deletions scripts/backup-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

DIR=backup

mkdir -p $DIR

function cleanup {
# Delete oldest backup
candidate="$(find $DIR -type f | sort | head -n 1)"
echo "Deleting $candidate"
rm "$candidate"
}

# Make sure backup directory doesn't take more than 30gb (+the new backup)
while [ "$(du -s $DIR | cut -f1)" -gt 3000000 ]; do
cleanup
done

cp movie.db "$DIR/$(date +%Y-%m-%d-%H-%M-%S)-movie.db"

0 comments on commit 867e3c7

Please sign in to comment.