-
-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4725 from rubyforgood/clock-backup
Add RDS backup script
- Loading branch information
Showing
3 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
desc "Update the development db to what is being used in prod" | ||
task :backup_db => :environment do | ||
system("echo Performing dump of the database.") | ||
|
||
current_time = Time.current.strftime("%Y%m%d%H%M%S") | ||
|
||
system("echo Copying of the database...") | ||
backup_filename = "#{current_time}.rds.dump" | ||
system("PGPASSWORD=#{ENV["DIAPER_DB_PASSWORD"]} pg_dump -Fc -v --host=#{ENV["DIAPER_DB_HOST"]} --username=#{ENV["DIAPER_DB_USERNAME"]} --dbname=#{ENV["DIAPER_DB_DATABASE"]} -f #{backup_filename}") | ||
|
||
account_name = ENV["AZURE_STORAGE_ACCOUNT_NAME"] | ||
account_key = ENV["AZURE_STORAGE_ACCESS_KEY"] | ||
|
||
blob_client = Azure::Storage::Blob::BlobService.create( | ||
storage_account_name: account_name, | ||
storage_access_key: account_key | ||
) | ||
|
||
system("echo Uploading #{backup_filename}") | ||
blob_client.create_block_blob("backups", backup_filename, File.read(backup_filename)) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters