fetch-prod-db uses the previous night's backup

to prevent loading a corrupt db file
This commit is contained in:
Mike Dalessio
2025-09-23 09:26:40 -04:00
parent e8f6323cf0
commit 9a73388403
+3 -3
View File
@@ -10,13 +10,13 @@ end
tenant_id = ARGV[0]
CONTAINER = "fizzy-web-production-b2f4038ea1fd054e313308940d9e445428f35b23"
REMOPTE_PATH = "/rails/storage/tenants/production/#{tenant_id}/db/main.sqlite3"
REMOTE_PATH = "/rails/storage/tenants/production/#{tenant_id}/db/main.sqlite3.1"
Dir.mktmpdir do |tmpdir|
local_file = File.join(tmpdir, "main.sqlite3")
puts "→ Copying #{REMOPTE_PATH} from container to #{local_file}"
cmd = %(ssh app@fizzy-app-101 "docker cp #{CONTAINER}:#{REMOPTE_PATH} -" | tar -xOf - > #{local_file})
puts "→ Copying #{REMOTE_PATH} from container to #{local_file}"
cmd = %(ssh app@fizzy-app-101 "docker cp #{CONTAINER}:#{REMOTE_PATH} -" | tar -xOf - > #{local_file})
system(cmd) or abort("Failed to copy database file")
puts "→ Running script/load-prod-db-in-dev.rb with #{local_file}"