lib/capistrano/ops/capistrano/v3/tasks/backup.rake in capistrano-ops-0.2.3 vs lib/capistrano/ops/capistrano/v3/tasks/backup.rake in capistrano-ops-0.2.4

- old
+ new

@@ -1,29 +1,25 @@ # frozen_string_literal: true +require_relative 'backup/backup_helper' + namespace :backup do + include BackupHelper # Default to :app role rake_roles = fetch(:rake_roles, :app) - desc 'create a backup of the server database' + desc 'create a backup of the server database (deprecated, use backup:database:create instead)' task :create do on roles(rake_roles) do - env = "RAILS_ENV=#{fetch(:stage)}" - # rubocop:disable Layout/LineLength - path_cmd = "PATH=$HOME/.rbenv/versions/#{RUBY_VERSION}/bin:$PATH" - # rubocop:enable Layout/LineLength - execute "cd #{release_path} && #{path_cmd} && #{env} BACKUPS_ENABLED=true bundle exec rake pg:dump" + warn "deprecated: use 'backup:database:create' instead, in future versions this task will be removed" + execute "#{prepare_env} BACKUPS_ENABLED=true EXTERNAL_BACKUP_ENABLED=false bundle exec rake pg:dump" end end - desc 'pull latest database backups from server to local' + desc 'pull latest database backups from server to local (deprecated, use backup:database:pull instead)' task :pull do on roles(rake_roles) do - # rubocop:disable Layout/LineLength - execute "cd #{shared_path}/backups && tar -czf #{shared_path}/backups.tar.gz $(ls -lt | grep -E -i '.{0,}\.dump' | head -n 1 | awk '{print $9}')" - # rubocop:enable Layout/LineLength - download! "#{shared_path}/backups.tar.gz", 'backups.tar.gz' - execute "rm #{shared_path}/backups.tar.gz" - system 'tar -xzf backups.tar.gz' - system 'rm backups.tar.gz' + warn "deprecated: use 'backup:database:pull' instead, in future versions this task will be removed" + backup_file = backup_file_name('database') + download! "#{shared_path}/backups/#{backup_file}" end end end