the tool to backup stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

24 lines
662 B

from fabric import Connection, Config, Result
import json
import os
def main():
backup_path = '/mnt/sda/backups'
with open('config.json', 'r') as config_file:
config = json.load(config_file)
for server in config.keys:
conn = Connection(host=server, port=22)
for service in config[server].keys:
backup_dir = '{}/{}'.format(backup_path, service)
if not os.path.exists(backup_dir):
os.mkdir(backup_dir)
conn.get(config[server][service], backup_dir)
conn.run('rm config[server][service]')
if __name__ == '__main__':
main()