text stringlengths 0 828 |
|---|
self.export_pgpassword('source') |
args = [ |
""pg_dump"", |
""-Fc"", |
""--no-acl"", |
""--no-owner"", |
""--dbname=%s"" % self.databases['source']['name'], |
""--file=%s"" % db_file, |
] |
args.extend(self.databases['source']['args']) |
subprocess.check_call(args) |
return db_file" |
917,"def drop_database(self): |
"""""" Drop postgres database. """""" |
self.print_message(""Dropping database '%s'"" % self.databases['destination']['name']) |
self.export_pgpassword('destination') |
args = [ |
""dropdb"", |
""--if-exists"", |
self.databases['destination']['name'], |
] |
args.extend(self.databases['destination']['args']) |
subprocess.check_call(args)" |
918,"def create_database(self): |
"""""" Create postgres database. """""" |
self.print_message(""Creating database '%s'"" % self.databases['destination']['name']) |
self.export_pgpassword('destination') |
args = [ |
""createdb"", |
self.databases['destination']['name'], |
] |
args.extend(self.databases['destination']['args']) |
for arg in self.databases['destination']['args']: |
if arg[:7] == '--user=': |
args.append('--owner=%s' % arg[7:]) |
subprocess.check_call(args)" |
919,"def replace_postgres_db(self, file_url): |
"""""" Replace postgres database with database from specified source. """""" |
self.print_message(""Replacing postgres database"") |
if file_url: |
self.print_message(""Sourcing data from online backup file '%s'"" % file_url) |
source_file = self.download_file_from_url(self.args.source_app, file_url) |
elif self.databases['source']['name']: |
self.print_message(""Sourcing data from database '%s'"" |
% self.databases['source']['name']) |
source_file = self.dump_database() |
else: |
self.print_message(""Sourcing data from local backup file %s"" % self.args.file) |
source_file = self.args.file |
self.drop_database() |
self.create_database() |
source_file = self.unzip_file_if_necessary(source_file) |
self.print_message(""Importing '%s' into database '%s'"" |
% (source_file, self.databases['destination']['name'])) |
args = [ |
""pg_restore"", |
""--no-acl"", |
""--no-owner"", |
""--dbname=%s"" % self.databases['destination']['name'], |
source_file, |
] |
args.extend(self.databases['destination']['args']) |
subprocess.check_call(args)" |
920,"def get_file_url_for_heroku_app(self, source_app): |
"""""" Get latest backup URL from heroku pg:backups (or pgbackups). """""" |
self.print_message(""Getting backup url for Heroku app '%s'"" % source_app) |
args = [ |
""heroku"", |
""pg:backups:url"", |
""--app=%s"" % source_app, |
] |
if self.args.use_pgbackups: |
args = [ |
""heroku"", |
""pgbackups:url"", |
""--app=%s"" % source_app, |
] |
return subprocess.check_output(args).strip().decode('ascii')" |
921,"def capture_heroku_database(self): |
"""""" Capture Heroku database backup. """""" |
self.print_message(""Capturing database backup for app '%s'"" % self.args.source_app) |
args = [ |
""heroku"", |
""pg:backups:capture"", |
""--app=%s"" % self.args.source_app, |
] |
if self.args.use_pgbackups: |
args = [ |
""heroku"", |
""pgbackups:capture"", |
""--app=%s"" % self.args.source_app, |
""--expire"", |
] |
subprocess.check_call(args)" |
922,"def reset_heroku_database(self): |
"""""" Reset Heroku database. """""" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.