mirror of
https://github.com/eduardolat/pgbackweb.git
synced 2026-01-23 21:19:31 -06:00
Add local support for soft deleting execution backups
This commit is contained in:
@@ -25,16 +25,23 @@ func (s *Service) SoftDeleteExecution(
|
||||
return err
|
||||
}
|
||||
|
||||
if execution.ExecutionPath.Valid {
|
||||
if execution.ExecutionPath.Valid && !execution.BackupIsLocal {
|
||||
err := s.ints.StorageClient.S3Delete(
|
||||
execution.DecryptedDestinationAccessKey, execution.DecryptedDestinationSecretKey,
|
||||
execution.DestinationRegion, execution.DestinationEndpoint,
|
||||
execution.DestinationBucketName, execution.ExecutionPath.String,
|
||||
execution.DestinationRegion.String, execution.DestinationEndpoint.String,
|
||||
execution.DestinationBucketName.String, execution.ExecutionPath.String,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if execution.ExecutionPath.Valid && execution.BackupIsLocal {
|
||||
err := s.ints.StorageClient.LocalDelete(execution.ExecutionPath.String)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return s.dbgen.ExecutionsServiceSoftDeleteExecution(ctx, executionID)
|
||||
}
|
||||
|
||||
@@ -4,15 +4,26 @@ SELECT
|
||||
executions.path as execution_path,
|
||||
|
||||
backups.id as backup_id,
|
||||
backups.is_local as backup_is_local,
|
||||
|
||||
destinations.bucket_name as destination_bucket_name,
|
||||
destinations.region as destination_region,
|
||||
destinations.endpoint as destination_endpoint,
|
||||
pgp_sym_decrypt(destinations.access_key, @encryption_key) AS decrypted_destination_access_key,
|
||||
pgp_sym_decrypt(destinations.secret_key, @encryption_key) AS decrypted_destination_secret_key
|
||||
(
|
||||
CASE WHEN destinations.access_key IS NOT NULL
|
||||
THEN pgp_sym_decrypt(destinations.access_key, sqlc.arg('encryption_key')::TEXT)
|
||||
ELSE ''
|
||||
END
|
||||
) AS decrypted_destination_access_key,
|
||||
(
|
||||
CASE WHEN destinations.secret_key IS NOT NULL
|
||||
THEN pgp_sym_decrypt(destinations.secret_key, sqlc.arg('encryption_key')::TEXT)
|
||||
ELSE ''
|
||||
END
|
||||
) AS decrypted_destination_secret_key
|
||||
FROM executions
|
||||
JOIN backups ON backups.id = executions.backup_id
|
||||
JOIN destinations ON destinations.id = backups.destination_id
|
||||
INNER JOIN backups ON backups.id = executions.backup_id
|
||||
LEFT JOIN destinations ON destinations.id = backups.destination_id
|
||||
WHERE executions.id = @execution_id;
|
||||
|
||||
-- name: ExecutionsServiceSoftDeleteExecution :exec
|
||||
|
||||
Reference in New Issue
Block a user