Commit 3be1bab9 authored by ThibautDemare's avatar ThibautDemare

Store the checkpoints inside a unique folder for each execution of this script

parent d3b8e22c
......@@ -8,22 +8,25 @@ def nbContainers():
result=run("docker ps -aq | wc -l", shell=True, stdout=PIPE).stdout.decode('utf-8')
return int(result)
def backup():
def backup(strDate):
running_containers = run("docker ps --format '{{.Names}}'", shell=True, stdout=PIPE, stderr=PIPE).stdout.decode('utf-8').split("\n")
for c in running_containers:
if c: # if c is not empty (it happens for the last element in p)
Popen("docker checkpoint create --leave-running=true --checkpoint-dir=$(pwd)/"+str(c)+"/Backup/ " + str(c) + " " + "checkpoint_" + str(c), shell=True)
Popen("docker checkpoint create --leave-running=true --checkpoint-dir=/mnt/TDEMARE/"+strDate+"/"+str(c)+"/Backup/ " + str(c) + " " + "checkpoint_" + str(c), shell=True)
def checkForBackupNeedsAndWait():
def checkForBackupNeedsAndWait(strDate):
# Should we backup the simulations ?
timeBetweenTwoBackup = timedelta(minutes=2) # We have one day between two backups
now =
if now > (lastBackup + timeBetweenTwoBackup):
# Sleep a bit: don't need to be awaken all the time
# Starting date
startingDate ="%Y-%m-%d-%H-%M-%S")
# The number of available CPU
nbCpus = multiprocessing.cpu_count()
......@@ -51,9 +54,9 @@ while nbSimStarted <= endingIndex:
# Loop if the current number of running containers is greater or equal than the number of available cpus
while nbCpus <= nbContainers():
while nbContainers() > 0:
# We started all the containers, but we still have to wait until their end
\ No newline at end of file
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment