summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2023-07-06 17:52:52 +0200
committerJose M. Guisado <jguisado@soleta.eu>2023-07-06 17:52:52 +0200
commit035995fc8c55740693575ca5f7b408bfc46c1f7d (patch)
tree002405879fab533fd5258a896bdd96f1bd42b614 /src
parent5c3cf47023c26dad486df0421f69327a33c3ed89 (diff)
live: add image backup option in image creationv1.3.1
Backup image file if image creation request included "backup": true This only applies when the target image is already present in the repository folder before running the partclone subprocess. This parameter is ignored if the target image is not present in the repository.
Diffstat (limited to 'src')
-rw-r--r--src/live/ogOperations.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py
index 8e5da48..df13816 100644
--- a/src/live/ogOperations.py
+++ b/src/live/ogOperations.py
@@ -6,6 +6,7 @@
# Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
+import datetime
import hashlib
import logging
import os
@@ -404,6 +405,7 @@ class OgLiveOperations:
partition = int(request.getPartition())
name = request.getName()
repo = request.getRepo()
+ backup = request.getBackup()
image_path = f'/opt/opengnsys/images/{name}.img'
self._ogbrowser_clear_logs()
@@ -446,6 +448,10 @@ class OgLiveOperations:
logfile = open('/tmp/command.log', 'wb', 0)
+ if os.path.exists(image_path) and backup:
+ now = datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S")
+ shutil.move(image_path, f'{image_path}_{now}')
+
p1 = Popen(cmd1, stdout=PIPE, stderr=logfile)
p2 = Popen(cmd2, stdin=p1.stdout)
p1.stdout.close()