Skip to content

Commit

Permalink
Merge pull request #1 from Oxalide/processing_root_files
Browse files Browse the repository at this point in the history
processing root files
  • Loading branch information
rekcah78 authored May 18, 2017
2 parents 8f6e07e + be68b1e commit 91cce25
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ def runner(args, index, job):
logging.error('rclone not found')
sys.exit(2)

def runner_files(args, directories):
excludes = ' --exclude '.join(directories)
try:
rcode = subprocess.call(["/usr/local/bin/rclone", "sync", "--exclude", excludes, args.dir, args.rclone+":"+args.bucket, "--quiet"])
if rcode != 0:
logging.error('Backup of files in %s : Failed', args.dir)
else:
logging.info('Backup of files in %s : OK', args.dir)
except:
logging.error('rclone not found')
sys.exit(2)

parser = argparse.ArgumentParser(description='Multi runner backup to S3.')
parser.add_argument('--dir', '-D', required=True, help='root backup (ex: /home/)')
parser.add_argument('--bucket', '-B', required=True, help='s3 bucket (ex: backup-efs)')
Expand All @@ -28,7 +40,7 @@ def runner(args, index, job):
logging.basicConfig(filename=str(args.log),format='%(asctime)s %(message)s', level=logging.INFO)
max_jobs = int(args.jobs)

directories = []
directories = list()
for fname in os.listdir(args.dir):
path = os.path.join(args.dir, fname)
if os.path.isdir(path):
Expand Down Expand Up @@ -59,6 +71,7 @@ def runner(args, index, job):
jobs.append([])
jobs[-1].append(directory)

runner_files(args, directories)
threads = []

for index, run in enumerate(jobs, start=1):
Expand Down

0 comments on commit 91cce25

Please sign in to comment.