Back to issue from pre-refactor!
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled
This commit is contained in:
parent
fb6974b51a
commit
d80820db15
@ -90,7 +90,7 @@ namespace dropshell
|
|||||||
ASSERT(ctx.args.size() == 3, "Invalid number of arguments");
|
ASSERT(ctx.args.size() == 3, "Invalid number of arguments");
|
||||||
std::string server = ctx.args[0];
|
std::string server = ctx.args[0];
|
||||||
std::string service = ctx.args[1];
|
std::string service = ctx.args[1];
|
||||||
std::string backup_file = ctx.args[2];
|
std::string backup_arg = ctx.args[2];
|
||||||
|
|
||||||
server_env_manager server_env(server);
|
server_env_manager server_env(server);
|
||||||
if (!server_env.is_valid())
|
if (!server_env.is_valid())
|
||||||
@ -106,7 +106,7 @@ namespace dropshell
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::optional<shared_commands::cBackupFileName> backup_details;
|
std::optional<shared_commands::cBackupFileName> backup_details;
|
||||||
if (backup_file == "latest")
|
if (backup_arg == "latest")
|
||||||
{ // special case.
|
{ // special case.
|
||||||
std::vector<shared_commands::cBackupFileName> backups = get_backup_files(server, service, service_info.template_name); // this service only (and also match template in case something changed there!).
|
std::vector<shared_commands::cBackupFileName> backups = get_backup_files(server, service, service_info.template_name); // this service only (and also match template in case something changed there!).
|
||||||
if (backups.empty())
|
if (backups.empty())
|
||||||
@ -117,15 +117,15 @@ namespace dropshell
|
|||||||
}
|
}
|
||||||
backup_details = backups[0];
|
backup_details = backups[0];
|
||||||
} else {
|
} else {
|
||||||
backup_details = shared_commands::cBackupFileName(backup_file);
|
backup_details = shared_commands::cBackupFileName(backup_arg);
|
||||||
|
if (!backup_details->is_valid())
|
||||||
|
{
|
||||||
|
error << "Invalid backup file: " << backup_arg << std::endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool backup_details_okay = backup_details.has_value() && backup_details->is_valid();
|
ASSERT(backup_details.has_value() && backup_details->is_valid(), "Invalid backup file.");
|
||||||
if (!backup_details_okay)
|
|
||||||
{
|
|
||||||
error << "Invalid backup file: " << backup_file << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string local_backups_dir = gConfig().get_local_backup_path();
|
std::string local_backups_dir = gConfig().get_local_backup_path();
|
||||||
if (local_backups_dir.empty() || !std::filesystem::exists(local_backups_dir))
|
if (local_backups_dir.empty() || !std::filesystem::exists(local_backups_dir))
|
||||||
@ -133,7 +133,7 @@ namespace dropshell
|
|||||||
error << "Error: Local backups directory not found: " << local_backups_dir << std::endl;
|
error << "Error: Local backups directory not found: " << local_backups_dir << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
std::string local_backup_file_path = (std::filesystem::path(local_backups_dir) / backup_file).string();
|
std::string local_backup_file_path = (std::filesystem::path(local_backups_dir) / backup_details->get_filename()).string();
|
||||||
if (!std::filesystem::exists(local_backup_file_path))
|
if (!std::filesystem::exists(local_backup_file_path))
|
||||||
{
|
{
|
||||||
error << "Error: Backup file not found at " << local_backup_file_path << std::endl;
|
error << "Error: Backup file not found at " << local_backup_file_path << std::endl;
|
||||||
@ -177,7 +177,7 @@ namespace dropshell
|
|||||||
{ // restore service from backup
|
{ // restore service from backup
|
||||||
info << "3) Restoring service data from backup..." << std::endl;
|
info << "3) Restoring service data from backup..." << std::endl;
|
||||||
std::string remote_backups_dir = remotepath::backups(server);
|
std::string remote_backups_dir = remotepath::backups(server);
|
||||||
std::string remote_backup_file_path = remote_backups_dir + "/" + backup_file;
|
std::string remote_backup_file_path = remote_backups_dir + "/" + backup_details->get_filename();
|
||||||
|
|
||||||
// Copy backup file from local to server
|
// Copy backup file from local to server
|
||||||
if (!shared_commands::scp_file_to_remote(server_env, local_backup_file_path, remote_backup_file_path, false))
|
if (!shared_commands::scp_file_to_remote(server_env, local_backup_file_path, remote_backup_file_path, false))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user