add loop switch
This commit is contained in:
parent
afb0f69853
commit
dc7d614d74
1 changed files with 9 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
||||||
import argparse
|
import argparse
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from apscheduler.schedulers.background import BackgroundScheduler
|
from apscheduler.schedulers.background import BackgroundScheduler
|
||||||
|
@ -43,6 +44,8 @@ def backup(socket, outdir, stack, services):
|
||||||
])
|
])
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="backup a rancher services docker volumes")
|
parser = argparse.ArgumentParser(description="backup a rancher services docker volumes")
|
||||||
|
parser.add_argument('--loop', action='store_true',
|
||||||
|
help="loop forever, run backup daily")
|
||||||
parser.add_argument('socket', default='unix://var/run/docker.sock',
|
parser.add_argument('socket', default='unix://var/run/docker.sock',
|
||||||
help="docker socket")
|
help="docker socket")
|
||||||
parser.add_argument('outdir')
|
parser.add_argument('outdir')
|
||||||
|
@ -59,6 +62,7 @@ scheduler.add_job(
|
||||||
days=1,
|
days=1,
|
||||||
args=(args.socket, args.outdir, args.stack, args.services),
|
args=(args.socket, args.outdir, args.stack, args.services),
|
||||||
)
|
)
|
||||||
|
if 'loop' in args and args.loop:
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
time.sleep(20)
|
time.sleep(20)
|
||||||
|
|
Loading…
Reference in a new issue