From 81ff0044143bf0802d88193426c28ed9457bf15f Mon Sep 17 00:00:00 2001 From: jaydee Date: Sat, 1 Mar 2025 16:09:19 +0100 Subject: [PATCH] added v3 --- docker_backups.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docker_backups.py b/docker_backups.py index c1bff60..dd4dfb9 100644 --- a/docker_backups.py +++ b/docker_backups.py @@ -1,5 +1,8 @@ import subprocess import requests + +now = datetime.datetime.now() +DATETIME = now.strftime("%Y%m%d%H%M%S") print("Backup gitlab") cmnd = 'docker exec -t gitlab gitlab-backup create SKIP=artifacts,repositories,registry,uploads,builds,pages,lfs,packages,terraform_state' status, output = subprocess.getstatusoutput(cmnd) @@ -11,7 +14,7 @@ status, output = subprocess.getstatusoutput(cmnd) cmnd = "docker exec --user www-data nextcloud-app-1 php occ maintenance:mode --off" status, output = subprocess.getstatusoutput(cmnd) - +print("Backup portainer") headers = { 'Content-Type': 'application/json; charset=utf-8', 'x-api-key':'ptr_gfwpbP4AUDhZ4uoPmSfNUGqZq+gescoele8reP/l/GU=', @@ -28,5 +31,5 @@ response = requests.post('https://portainer.sectorq.eu/api/backup', headers=head #data = '{ "password": "" }' #response = requests.post('https://portainer.sectorq.eu/api/backup', headers=headers, data=data, verify=False) -with open('/share/docker_data/__backups/portainer_snapshot.tar.gz', 'wb') as f: +with open(f'/share/docker_data/__backups/portainer_snapshot_{DATETIME}.tar.gz', 'wb') as f: f.write(response.content) \ No newline at end of file