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.
 

37 lines
1.2 KiB

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)
print(config)
for host in config:
print('conect to ' + host)
conn = Connection(host=host, port=22)
for service in config[host]:
backup_dir = '{}/{}'.format(backup_path, service).lower()
print('from' + config[host][service] + ' to ' + backup_dir)
conn.get(config[host][service], backup_dir.lower())
conn.run('rm {}'.format(config[host][service]))
#for server in config:
# print('conect to ' + server)
# #conn = Connection(host=server, port=22)
# for service in server:
# backup_dir = '{}/{}'.format(backup_path, service)
# print('to ' + backup_dir)
# #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()