相关疑难解决方法(0)

Postgres:在重新创建/重新填充bash脚本之前清除整个数据库

我正在编写一个shell脚本(将成为一个cronjob),它将:

1:转储我的生产数据库

2:将转储导入我的开发数据库

在步骤1和2之间,我需要清除开发数据库(删除所有表?).如何从shell脚本中最好地完成?到目前为止,它看起来像这样:

#!/bin/bash
time=`date '+%Y'-'%m'-'%d'`
# 1. export(dump) the current production database
pg_dump -U production_db_name > /backup/dir/backup-${time}.sql

# missing step: drop all tables from development database so it can be re-populated

# 2. load the backup into the development database
psql -U development_db_name < backup/dir/backup-${time}.sql
Run Code Online (Sandbox Code Playgroud)

database postgresql backup

116
推荐指数
8
解决办法
17万
查看次数

标签 统计

backup ×1

database ×1

postgresql ×1