Skip to content

Commit

Permalink
backup: Use the default zulip backup system.
Browse files Browse the repository at this point in the history
  • Loading branch information
hackerkid committed Aug 25, 2020
1 parent 5b2ec71 commit 0d630db
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ prepareDirectories() {
rm -rf /home/zulip/uploads
ln -sfT "$DATA_DIR/uploads" /home/zulip/uploads
chown zulip:zulip -R "$DATA_DIR/uploads"
chown zulip:zulip -R "$DATA_DIR/backups"
# Link settings folder
if [ "$LINK_SETTINGS_TO_DATA" = "True" ] || [ "$LINK_SETTINGS_TO_DATA" = "true" ]; then
# Create settings directories
Expand Down Expand Up @@ -440,21 +441,11 @@ appManagePy() {
exec su zulip -c "/home/zulip/deployments/current/manage.py $(printf '%q ' "$COMMAND" "$@")"
}
appBackup() {
echo "Starting backup process ..."
if [ -d "/tmp/backup-$(date "%D-%H-%M-%S")" ]; then
echo "Temporary backup folder for \"$(date "%D-%H-%M-%S")\" already exists. Aborting."
echo "Backup process failed. Exiting."
exit 1
fi
local BACKUP_FOLDER
BACKUP_FOLDER="/tmp/backup-$(date "%D-%H-%M-%S")"
mkdir -p "$BACKUP_FOLDER"
waitingForDatabase
pg_dump -h "$DB_HOST" -p "$DB_HOST_PORT" -U "$DB_USER" "$DB_NAME" > "$BACKUP_FOLDER/database-postgres.sql"
tar -zcvf "$DATA_DIR/backups/backup-$(date "%D-%H-%M-%S").tar.gz" "$BACKUP_FOLDER/"
rm -r "${BACKUP_FOLDER:?}/"
echo "Backup process succeeded."
exit 0
echo "Starting backup process"
local BACKUP_FOLDER
BACKUP_FOLDER="/data/backups/backup-$(date "+%Y-%b-%d-%H-%M-%S").tar.gz"
exec su zulip -c "/home/zulip/deployments/current/manage.py backup --output $BACKUP_FOLDER"
}
appRestore() {
echo "Starting restore process ..."
Expand Down Expand Up @@ -494,9 +485,7 @@ appRestore() {
done
echo "!! WARNING !! Starting restore process ... !! WARNING !!"
waitingForDatabase
tar -zxvf "$DATA_DIR/backups/$BACKUP_FILE" -C /tmp
psql -h "$DB_HOST" -p "$DB_HOST_PORT" -U "$DB_USER" "$DB_NAME" < "/tmp/$(basename "$BACKUP_FILE" | cut -d. -f1)/database-postgres.sql"
rm -r "/tmp/$(basename | cut -d. -f1)/"
/home/zulip/deployments/current/scripts/setup/restore-backup "$DATA_DIR/backups/$BACKUP_FILE"
echo "Restore process succeeded. Exiting."
exit 0
}
Expand Down

0 comments on commit 0d630db

Please sign in to comment.