-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f236ea6
commit dcf0fe5
Showing
3 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
# This scripts creates a rotating backup of the last 7 days. | ||
# Subfolder 01 contains the newewst, subfolder 07 the latest backup. | ||
|
||
# modify the following to suit your environment | ||
source /opt/faf/config/extra/mongodb/mongodb.env | ||
export DB_BACKUP="/opt/faf/backups/mongodb" | ||
|
||
echo "*** MongoDB backup" | ||
echo "* Rotate existing backups" | ||
echo "------------------------" | ||
|
||
rm -rf $DB_BACKUP/07 | ||
mv $DB_BACKUP/06 $DB_BACKUP/07 | ||
mv $DB_BACKUP/05 $DB_BACKUP/06 | ||
mv $DB_BACKUP/04 $DB_BACKUP/05 | ||
mv $DB_BACKUP/03 $DB_BACKUP/04 | ||
mv $DB_BACKUP/02 $DB_BACKUP/03 | ||
mv $DB_BACKUP/01 $DB_BACKUP/02 | ||
mkdir -p $DB_BACKUP/01 | ||
|
||
echo "* Creating backup..." | ||
echo "------------------------" | ||
docker-compose --compatibility --project-directory /opt/faf -f /opt/faf/faf-extra.yml exec mongodb mongodump -u "$MONGO_NODEBB_USERNAME" -p "$MONGO_NODEBB_PASSWORD" -d "$MONGO_NODEBB_DATABASE" --archive=/backup/archive.gz --gzip | ||
mv ./data/mongodb/backup/archive.gz "$DB_BACKUP/01/$(date +"%Y-%m-%d-%H-%M-%S").gz" | ||
echo "Done" | ||
exit 0 |