17 lines
445 B
Plaintext
17 lines
445 B
Plaintext
|
#!/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:
|