aboutsummaryrefslogtreecommitdiff
path: root/src/palhm/mod/aws.py
diff options
context:
space:
mode:
authorDavid Timber <dxdt@dev.snart.me>2022-05-13 14:45:59 +0800
committerDavid Timber <dxdt@dev.snart.me>2022-05-13 14:45:59 +0800
commit515bf01a057f0b40d89c6b7b247eb4e2fc19d1b7 (patch)
tree1a625d2a85b858227c3bd67955da3da90be49bda /src/palhm/mod/aws.py
parenta01c87416b241315a9268bb4eb5206ade8328069 (diff)
Impl ...
- launch.json: change debug cwd to the project root dir - Add subcmd "mods" - Docs - Tidy up sample and debug config files - Change core exec - 'dnf-list-instaled' -> 'rpm-list-installed' as dnf does not work on ro fs - Accept the exit code 1 from tar(allow live fs change) - Add the generic sample config - Fix 'run' subcmd not accepting empty task-id - Change module loading: modules are not required to have the 'backup_backends' var - Reduce required Python version by removing the use of match ... case - Fix 'exec-append' not taking 'env' into account - Remove use of exceptions from irrelevant packages - Fix unimpl methods of NullBackupBackend - Tidy up instantiation of raised exceptions - Change "include" behaviour - Relative config paths are now resolved like #include C preprocessor - Fix bug where "include" circular ref checked is not done with absolute paths of config files - Add own exception hierachy - aws-s3: change storage class only when "rot-storage-class" is different from "sink-storage-class"
Diffstat (limited to 'src/palhm/mod/aws.py')
-rw-r--r--src/palhm/mod/aws.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/palhm/mod/aws.py b/src/palhm/mod/aws.py
index fcb16f1..01fb8bc 100644
--- a/src/palhm/mod/aws.py
+++ b/src/palhm/mod/aws.py
@@ -7,6 +7,7 @@ from typing import Callable, Iterable
import boto3
import botocore
from palhm import BackupBackend, Exec, GlobalContext
+from palhm.exceptions import APIFailError
class CONST (Enum):
@@ -50,10 +51,13 @@ class S3BackupBackend (BackupBackend):
Key = self.cur_backup_key)
sleep(1)
# Make sure we don't proceed
- raise FileExistsError(self.cur_backup_uri)
+ raise FileExistsError(
+ "Failed to set up a backup dir. Check the prefix function",
+ self.cur_backup_uri)
except botocore.exceptions.ClientError as e:
- if e.response["Error"]["Code"] != "404": # expected status code
- raise
+ c = e.response["Error"]["Code"]
+ if c != "404": # expected status code
+ raise APIFailError("Unexpected status code", c)
return super().open(ctx)
@@ -125,8 +129,9 @@ class S3BackupBackend (BackupBackend):
o_key = i["Key"]
o_size = i.get("Size", 0)
if not o_key.startswith(self.root_key):
- raise RuntimeError("The endpoint returned an object " +
- "irrelevant to the request: " + o_key)
+ raise APIFailError(
+ "The endpoint returned an object irrelevant to the request",
+ o_key)
l = o_key.find("/", len(prefix))
if l >= 0:
@@ -200,7 +205,7 @@ class S3BackupBackend (BackupBackend):
def rotate (self, ctx: GlobalContext):
ret = super()._do_fs_rotate(ctx)
- if self.sc_rot:
+ if self.sc_rot and self.sc_rot != self.sc_sink:
def chsc (k):
self.client.copy_object(
Bucket = self.bucket,