fix backup script
This commit is contained in:
parent
e537033319
commit
a35e9d2d44
1 changed files with 3 additions and 3 deletions
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
if [ "$(whoami)" != "postgres" ]; then
|
||||
echo -e "This script has to be run as \033[1mpostgres\033[0m user"
|
||||
if [ "$(whoami)" != "root" ]; then
|
||||
echo -e "This script has to be run as \033[1mroot\033[0m user"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
|
|
@ -11,5 +11,5 @@ DATE=$(date --utc +%F_%H-%M)
|
|||
BACKUP_DIR=/var/backups/postgresql
|
||||
BACKUP_FILE=$BACKUP_DIR/backup-$DATE.sql.gz
|
||||
|
||||
pg_dump -- lamassu | gzip > $BACKUP_FILE
|
||||
su postgres -c "pg_dump lamassu" | gzip > $BACKUP_FILE
|
||||
find $BACKUP_DIR -maxdepth 1 -mtime +$DAYS_TO_KEEP -exec rm -f '{}' ';'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue