Skip to content

Commit

Permalink
Merge pull request #15 from woblerr/backup_delete_local
Browse files Browse the repository at this point in the history
Add local backups support for backup-delete command.
  • Loading branch information
woblerr committed Jun 4, 2024
2 parents b9c9589 + 9bb4c94 commit 8848226
Show file tree
Hide file tree
Showing 131 changed files with 19,103 additions and 131 deletions.
46 changes: 36 additions & 10 deletions COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,28 @@ By default, the existence of dependent backups is checked and deletion process i
unless the --cascade option is passed in.

If backup already deleted, the deletion process is skipped, unless --force option is specified.
If errors occur during the deletion process, the errors can be ignored using the --ignore-errors option.
The --ignore-errors option can be used only with --force option.

By default, he deletion will be performed for local backup (in development).
By default, the deletion will be performed for local backup.

The full path to the backup directory can be set using the --backup-dir option.

For local backups the following logic are applied:
* If the --backup-dir option is specified, the deletion will be performed in provided path.
* If the --backup-dir option is not specified, but the backup was made with --backup-dir flag for gpbackup, the deletion will be performed in the backup manifest path.
* If the --backup-dir option is not specified and backup directory is not specified in backup manifest, the deletion will be performed in backup folder in the master and segments data directories.
* If backup is not local, the error will be returned.

For control over the number of parallel processes and ssh connections to delete local backups, the --parallel-processes option can be used.

The storage plugin config file location can be set using the --plugin-config option.
The full path to the file is required. In this case, the deletion will be performed using the storage plugin.

For non local backups the following logic are applied:
* If the --plugin-config option is specified, the deletion will be performed using the storage plugin.
* If backup is local, the error will be returned.

The gpbackup_history.db file location can be set using the --history-db option.
Can be specified only once. The full path to the file is required.

Expand All @@ -153,11 +169,14 @@ Usage:
gpbackman backup-delete [flags]

Flags:
--cascade delete all dependent backups for the specified backup timestamp
--force try to delete, even if the backup already mark as deleted
-h, --help help for backup-delete
--plugin-config string the full path to plugin config file
--timestamp stringArray the backup timestamp for deleting, could be specified multiple times
--backup-dir string the full path to backup directory
--cascade delete all dependent backups for the specified backup timestamp
--force try to delete, even if the backup already mark as deleted
-h, --help help for backup-delete
--ignore-errors ignore errors when deleting backups
--parallel-processes int the number of parallel processes to delete local backups (default 1)
--plugin-config string the full path to plugin config file
--timestamp stringArray the backup timestamp for deleting, could be specified multiple times

Global Flags:
--history-db string full path to the gpbackup_history.db file
Expand All @@ -169,13 +188,20 @@ Global Flags:
## Examples
### Delete existing backup from local storage
Delete specific backup with specifying directory path:
```bash
./gpbackman backup-delete \
--timestamp 20230809232817 \
--backup-dir /some/path
```
The functionality is in development.
gpBackMan returns a message:
Delete specific backup with specifying the number of parallel processes:
```bash
[WARNING]:-The functionality is still in development
./gpbackman backup-delete \
--timestamp 20230809212220 \
--parallel-processes 5
```
### Delete existing backup using storage plugin
Delete specific backup:
```bash
Expand Down
8 changes: 4 additions & 4 deletions cmd/backup_clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ func backupCleanDBPlugin(deleteCascade bool, cutOffTimestamp, pluginConfigPath s
gplog.Debug(textmsg.InfoTextBackupDeleteList(backupList))
// Execute deletion for each backup.
// Use backupDeleteDBPlugin function from backup-delete command.
// Don't use force deletes for mass deletion.
err = backupDeleteDBPlugin(backupList, deleteCascade, false, pluginConfigPath, pluginConfig, hDB)
// Don't use force deletes and ignore errors for mass deletion.
err = backupDeleteDBPlugin(backupList, deleteCascade, false, false, pluginConfigPath, pluginConfig, hDB)
if err != nil {
return err
}
Expand All @@ -219,8 +219,8 @@ func backupCleanFilePlugin(deleteCascade bool, cutOffTimestamp, pluginConfigPath
gplog.Debug(textmsg.InfoTextBackupDeleteList(backupList))
// Execute deletion for each backup.
// Use backupDeleteFilePlugin function from backup-delete command.
// Don't use force deletes for mass deletion.
err := backupDeleteFilePlugin(backupList, deleteCascade, false, pluginConfigPath, pluginConfig, parseHData)
// Don't use force deletes and ignore errors for mass deletion.
err := backupDeleteFilePlugin(backupList, deleteCascade, false, false, pluginConfigPath, pluginConfig, parseHData)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 8848226

Please sign in to comment.