Prechádzať zdrojové kódy

Split config file into a common part and a specific part

jherve 1 mesiac pred
rodič
commit
d3071835dd
3 zmenil súbory, kde vykonal 39 pridanie a 32 odobranie
  1. 3 29
      data/borgmatic.d/config.yaml
  2. 31 0
      data/borgmatic/common.yaml
  3. 5 3
      start.py

+ 3 - 29
data/borgmatic.d/config.yaml

@@ -1,38 +1,12 @@
+<<: !include /etc/borgmatic/common.yaml
+
 source_directories:
   - /mnt/source/
-repositories:
-  - path: ssh://${STORAGE_BOX_USER}@${STORAGE_BOX_USER}.your-storagebox.de:23/./borg-repo
-
-remote_path: borg-1.4
-ssh_command: ssh -i ~/.ssh/${SSH_KEY_NAME}
 
-encryption_passphrase: "{credential file /credentials/borg_passphrase}"
-compression: lz4
-archive_name_format: 'backup-{hostname}-{now}'
+# source_directories_must_exist: true
 
 keep_hourly: 10
 keep_daily: 7
 keep_weekly: 4
 keep_monthly: 12
 keep_yearly: 10
-
-checks:
-  - name: repository
-    frequency: 2 weeks
-  - name: archives
-    frequency: always
-  - name: extract
-    frequency: 2 weeks
-  - name: data
-    frequency: 1 month
-
-commands:
-  - before: everything
-    run:
-      - echo "Starting a backup job."
-  - after: everything
-    run:
-      - echo "Backup created."
-  - after: error
-    run:
-      - echo "Error while creating a backup."

+ 31 - 0
data/borgmatic/common.yaml

@@ -0,0 +1,31 @@
+repositories:
+  - path: ssh://${STORAGE_BOX_USER}@${STORAGE_BOX_USER}.your-storagebox.de:23/./borg-repo
+    label: hetzner
+
+remote_path: borg-1.4
+ssh_command: ssh -i ~/.ssh/${SSH_KEY_NAME}
+
+encryption_passphrase: "{credential file /credentials/borg_passphrase}"
+compression: lz4
+archive_name_format: 'backup-{hostname}-{now}'
+
+checks:
+  - name: repository
+    frequency: 2 weeks
+  - name: archives
+    frequency: always
+  - name: extract
+    frequency: 2 weeks
+  - name: data
+    frequency: 1 month
+
+commands:
+  - before: everything
+    run:
+      - echo "Starting a backup job."
+  - after: everything
+    run:
+      - echo "Backup created."
+  - after: error
+    run:
+      - echo "Error while creating a backup."

+ 5 - 3
start.py

@@ -24,12 +24,14 @@ def main():
     hostname = socket.gethostname()
     container_name = "borgmatic"
     ssh_auth_sock = os.getenv("SSH_AUTH_SOCK")
-    config_path = Path.cwd() / "data" / "borgmatic.d"
+    config_d_path = Path.cwd() / "data" / "borgmatic.d"
+    config_path = Path.cwd() / "data" / "borgmatic"
     credentials_path = Path.cwd() / "data" / "credentials"
     storage_box_env = credentials_path / "storage_box_env"
     ssh_config_path = Path.home() / ".ssh"
     volumes = [
-        f"{config_path}:/etc/borgmatic.d/",
+        f"{config_d_path}:/etc/borgmatic.d/",
+        f"{config_path}:/etc/borgmatic/",
         f"{credentials_path}:/credentials/",
         f"{ssh_config_path}:/root/.ssh",
         "borg_config:/root/.config/borg",
@@ -45,7 +47,7 @@ def main():
         ssh_key_name = "theenglishway.pub"
 
     volumes += [
-        f"{vol}:{to_source_path(vol)}:ro" for vol in data_sources
+        f"{vol}:{to_source_path(vol)}:ro" for vol in data_sources if vol.exists()
     ]
 
     volume_args = [a for vol in volumes for a in ["-v", vol]]