backup revision 486df98bbf3348cfb96e93c3e499d12435880bb5
require 'fileutils'
require 'pathname'
DATA_DIRS = %w(data/repositories data/git_daemon)
verbose: false, dry_run: true, sql_dump_without_su: false)
end
# We needed to create the directory for the script to continue later on.
puts "created backup in #{backup_instance_dir}"
end
puts "restored backup from #{backup_instance_dir}"
end
end
# Create directory even in dry run to let the script continue.
end
exec "pg_dump -U postgres -Fc #{db_name} > #{SQL_DUMP_FILE}"
else
exec "sudo -u postgres pg_dump -Fc #{db_name} > #{SQL_DUMP_FILE}"
end
end
end
end
end
puts "Error: Backup '#{backup_name}' does not exist in #{backup_root}."
exit
end
end
exec "pg_restore -c -U postgres -d #{db_name} #{SQL_DUMP_FILE}"
else
exec "sudo -u postgres pg_restore -c -d #{db_name} #{SQL_DUMP_FILE}"
end
end
end
end
end
end
end
def exec(command)
end
end
end
end
end
end
# We assume, this script runs in "RAILS_ROOT/script/".
BACKUP_ROOT = '/tmp/ontohub_backup'
case ARGV.first
when 'create'
when 'restore'
if ARGV.length == 1
puts 'To restore a backup, you need to specify one with the arguments'
puts '"restore backup_name"'
exit
end
else
puts 'unknown or missing parameter'
puts 'use parameter "create" or "restore <backup_name>"'
exit
end