17 lines
445 B
Django/Jinja
Executable File
17 lines
445 B
Django/Jinja
Executable File
#!/bin/bash
|
|
|
|
set -xeo pipefail
|
|
|
|
NOW=$(date +%Y-%m-%d_%H:%M:%S)
|
|
|
|
BACKUP_PATH="{{ backup_path }}/backup"
|
|
RESTORE_PATH="{{ backup_path }}/restore"
|
|
cd ${BACKUP_PATH}
|
|
docker exec postgres pg_dump -U drone -d drone -f /var/lib/pgbackup/backup_${NOW}.sql
|
|
LATEST_BACKUP=$(ls -1t *.sql | head -n1)
|
|
if [ "z${LATEST_BACKUP}" != "z" ]; then
|
|
cp "${BACKUP_PATH}/${LATEST_BACKUP}" "${RESTORE_PATH}/latest_backup.sql"
|
|
fi
|
|
|
|
# vim: set ft=sh et sw=0 ts=2 sts=0:
|