如何以gz格式从openshift备份我的数据库,以便我可以在我的localhost postgres数据库中导入它?我曾经使用this script:
class Test2
{
private int _x = -1; // The default value is -1
private int x{
get
{
return _x; // return whatever is in _x
}
set
{
_x = 5; // Change _x to 5 (or whatever is in value)
}
}
public Test2(){
Console.WriteLine("Test2: " + x); // should show -1
Test2.x = 8;
Console.WriteLine("Test2: " + x); // should show 8
}
}
然后导入:
NOW="$(date +"%Y-%m-%d")"
FILENAME="$OPENSHIFT_DATA_DIR/$OPENSHIFT_APP_NAME.$NOW.backup.sql.gz"
pg_dump $OPENSHIFT_APP_NAME | gzip > $FILENAME
如果我运行备用代码gunzip -c digrin27.2015-07-10.backup.sql.gz | psql digrin
,我会收到此错误:
pq_dump DB_NAME
pg_dump digrin
那么我该如何备份单独设备上的数据库呢?我尝试下载快照,但只下载了文件。
答案 0 :(得分:3)
pg_dump $OPENSHIFT_APP_NAME -h $OPENSHIFT_POSTGRESQL_DB_HOST | gzip > $OPENSHIFT_DATA_DIR/$OPENSHIFT_APP_NAME.$(date +"%Y-%m-%d").backup.sql.gz`