Browse Source

easy script to download and manage backups

master
Christian Urich 5 years ago
parent
commit
3b284f68ca
3 changed files with 33 additions and 0 deletions
  1. +24
    -0
      backup.py
  2. +0
    -0
      config.json
  3. +9
    -0
      config.json.example

+ 24
- 0
backup.py View File

@ -0,0 +1,24 @@
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()

+ 0
- 0
config.json View File


+ 9
- 0
config.json.example View File

@ -0,0 +1,9 @@
{
"host" : {
"service" : "path/to/backups/*"
},
"host2" : {
"service1" : "path/to/backups/*",
"service2" : "path/to/backups/*"
}
}

Loading…
Cancel
Save