AZLABS commited on
Commit
3565651
·
verified ·
1 Parent(s): cc9ee69

Update backup.sh

Browse files
Files changed (1) hide show
  1. backup.sh +7 -7
backup.sh CHANGED
@@ -1,17 +1,17 @@
1
  #!/bin/bash
2
 
3
- # 使用环境变量 PGPASSWORD 进行备份
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