Update backup.sh
Browse files
backup.sh
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
#!/bin/bash
|
2 |
|
3 |
-
#
|
4 |
export PGPASSWORD="$DB_POSTGRESDB_PASSWORD"
|
5 |
|
6 |
-
#
|
7 |
pg_dump -U "$DB_POSTGRESDB_USER" -d "$DB_POSTGRESDB_DATABASE" -F c -b -v -f "${WORKDIR}/backups/backup.dump"
|
8 |
|
9 |
-
#
|
10 |
if [ $? -eq 0 ]; then
|
11 |
-
echo "
|
12 |
else
|
13 |
-
echo "
|
14 |
fi
|
15 |
|
16 |
-
#
|
17 |
-
unset PGPASSWORD
|
|
|
1 |
#!/bin/bash
|
2 |
|
3 |
+
# Use environment variable PGPASSWORD for backup
|
4 |
export PGPASSWORD="$DB_POSTGRESDB_PASSWORD"
|
5 |
|
6 |
+
# Backup database to a fixed file name, overwriting the previous backup
|
7 |
pg_dump -U "$DB_POSTGRESDB_USER" -d "$DB_POSTGRESDB_DATABASE" -F c -b -v -f "${WORKDIR}/backups/backup.dump"
|
8 |
|
9 |
+
# Check if backup was successful
|
10 |
if [ $? -eq 0 ]; then
|
11 |
+
echo "Database backup successful"
|
12 |
else
|
13 |
+
echo "Database backup failed"
|
14 |
fi
|
15 |
|
16 |
+
# Clear environment variable
|
17 |
+
unset PGPASSWORD
|