@@ -15,7 +15,7 @@ task :fetch_latest_db do
1515 system ( "bin/rails db:environment:set RAILS_ENV=development" )
1616 system ( "bin/rails db:drop db:create" )
1717
18- puts "Restoring the database with #{ backup . name } "
18+ puts "Restoring the database with #{ backup . key } "
1919 backup_filepath = fetch_file_path ( backup )
2020 db_username = ENV [ "PG_USERNAME" ] . presence || ENV [ "USER" ] . presence || "postgres"
2121 db_host = ENV [ "PG_HOST" ] . presence || "localhost"
@@ -58,16 +58,16 @@ def fetch_latest_backups
5858 #
5959 # Retrieve the most up to date version of the DB dump
6060 #
61- backup = backups . select { |b | b . name . match? ( ".rds.dump" ) } . sort do |a , b |
61+ backup = backups . contents . select { |b | b . key . match? ( ".rds.dump" ) } . sort do |a , b |
6262 Time . parse ( a . last_modified ) <=> Time . parse ( b . last_modified )
6363 end . reverse . first
6464
6565 #
6666 # Download each of the backups onto the local disk in tmp
6767 #
6868 filepath = fetch_file_path ( backup )
69- puts "\n Downloading blob #{ backup . name } to #{ filepath } "
70- blob_client . get_object ( bucket : BUCKET_NAME , key : backup . name , response_target : filepath )
69+ puts "\n Downloading blob #{ backup . key } to #{ filepath } "
70+ blob_client . get_object ( bucket : BUCKET_NAME , key : backup . key , response_target : filepath )
7171
7272 #
7373 # At this point, the dumps should be stored on the local
@@ -77,11 +77,11 @@ def fetch_latest_backups
7777end
7878
7979def blob_client
80- Aws ::S3 ::Client . new
80+ Aws ::S3 ::Client . new ( region : 'us-east-2' )
8181end
8282
8383def fetch_file_path ( backup )
84- File . join ( Rails . root , 'tmp' , backup . name )
84+ File . join ( Rails . root , 'tmp' , File . basename ( backup . key ) )
8585end
8686
8787def replace_user_passwords
0 commit comments