diff options
-rw-r--r-- | src/live/ogOperations.py | 6 |
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() |