很抱歉,如果它是重复的,但我试图在这里找到答案,没有任何帮助。
所以,我已经阅读过像this和this这样的文章。我能够保存转储文件,我用pg:backups capture
命令创建了该转储文件。将其上传到s3并尝试使用以下命令恢复它:
heroku pg:backups restore DATABASE 'https://s3-eu-west-1.amazonaws.com/somebucket/uploads/tmp/b011.dump'
但它只是不起作用!在控制台中记录:
Unknown database: https://s3-eu-west-1.amazonaws.com/somebucket/uploads/tmp/b011.dump. Valid options are: DATABASE_URL, HEROKU_POSTGRESQL_SILVER_URL
尝试列出的选项而不是DATABASE
,但结果相同。我也尝试了其他托管,但结果相同。我也尝试从其他应用程序恢复它,如下所示:
heroku pg:backups restore myapp::b001 HEROKU_POSTGRESQL_SILVER --app myapp-cedar
但是它使用Backup oncampus::b001 not found.
记录但是,命令heroku pg:backups --app myapp
显示它存在。
=== Backups
ID Backup Time Status Size Database
---- ------------------------- ---------------------------------- ------ --------
b001 2015-03-13 18:10:14 +0000 Finished 2015-03-13 18:10:22 +0000 9.71MB ORANGE
不知道现在该做什么。希望有人能帮助我。
答案 0 :(得分:8)
命令的参数顺序很重要。在上面的第一个示例中,您有heroku pg:backups restore DATABASE 'https://s3-eu-west-1.amazonaws.com/somebucket/uploads/tmp/b011.dump'
,但该命令期望引用FIRST和db加载到第二个,这将给出heroku pg:backups restore 'https://s3-eu-west-1.amazonaws.com/somebucket/uploads/tmp/b011.dump' DATABASE
。我认为在新的东西中ID可能比URL更受欢迎,但只要该URL可访问,URL就应该起作用。希望有所帮助,否则让我知道,我们可以尝试其他一些东西。
答案 1 :(得分:1)
准备两个sh文件,如下所示 backup.sh
NOWDATE=`date +%Y-%m-%d`
BACKUPNAME=$NOWDATE.dump
export PGPASSWORD='<password>'
echo “Creating backup of database to $BACKUPNAME”
/usr/bin/pg_dump --host <urhostname> --port 5432 --username "<user>" --role "<role>" --no-password --format tar --blobs --verbose --file "./$BACKUPNAME" "dbname"
echo “Succesfully created database backup”
echo “Uploading backup to Amazon S3 bucket…”
s3cmd put $BACKUPNAME s3://path/to/$BACKUPNAME
echo “Successfully uploaded backup to S3″
echo “Deleting backup file…”
rm $BACKUPNAME
echo “Done”
restore.sh
NOWDATE=`date +%Y-%m-%d`
BACKUPNAME=$NOWDATE.dump
echo “downloading the file $BACKUPNAME”
s3cmd get s3://path/to/$BACKUPNAME
echo “Succesfully downloaded”
echo “Will restore it Please wait “
export PGPASSWORD='<password>'
pg_restore --host <host> --port 5432 --username "<user>" --dbname "<databasename>" --role "<role>" --no-password --verbose "./$BACKUPNAME"
echo “restoring the file $BACKUPNAME”
echo “Deleting backup file…”
rm -r $BACKUPNAME
echo “Done”
您需要配置s3cmd凭据,希望它有所帮助!
答案 2 :(得分:0)