about summary refs log tree commit diff
path: root/bundles/restic-backup/items.py
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/restic-backup/items.py')
-rw-r--r--bundles/restic-backup/items.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/bundles/restic-backup/items.py b/bundles/restic-backup/items.py
new file mode 100644
index 0000000..9ffc565
--- /dev/null
+++ b/bundles/restic-backup/items.py
@@ -0,0 +1,62 @@
+if node.os != "alpine":
+    raise BundleError(f"{node.name}: OS {node.os} is not supported.")
+
+files = {
+    "/usr/bin/resticw": {
+        "source": "resticw",
+        "content_type": "text",
+        "mode": "0755",
+    },
+    "/usr/bin/resticbackup": {
+        "source": "resticbackup",
+        "content_type": "text",
+        "mode": "0755",
+    },
+    "/usr/bin/resticrestore": {
+        "source": "resticrestore",
+        "content_type": "text",
+        "mode": "0755",
+    },
+    "/etc/restic/restic.conf": {
+        "source": "restic.conf",
+        "content_type": "mako",
+        "mode": "0600",
+    },
+    "/etc/restic/includes": {
+        "source": "includes",
+        "content_type": "mako",
+        "context": {
+            "paths": sorted(node.metadata.get("backup/includes", {})),
+        },
+    },
+    "/etc/restic/excludes": {
+        "source": "includes",
+        "content_type": "mako",
+        "context": {
+            "paths": sorted(node.metadata.get("backup/excludes", {})),
+        },
+    },
+    "/etc/periodic/weekly/restic-backup": {
+        "source": "cron_job",
+        "content_type": "mako",
+        "mode": "0755",
+        "needs": {
+            "bundle:tgnotify",
+        }
+    },
+}
+
+actions = {
+    f"initialize_restic_repository": {
+        "command": "resticw init",
+        "unless": "resticw cat config",
+        "needs": {
+            "file:/usr/bin/resticw",
+            "file:/etc/restic/restic.conf",
+        },
+        "triggered": True,
+        "triggered_by": {
+            "file:/etc/restic/restic.conf",
+        },
+    }
+}