rename backup_to_fileserver to backup_to_external
I've renamed the files because it makes more sense this way. Since I would like to add a function to check if an external disk is present.
This commit is contained in:
parent
2a41ab98fd
commit
acf5399b02
|
@ -66,3 +66,8 @@ Session.vim
|
||||||
.netrwhist
|
.netrwhist
|
||||||
*~
|
*~
|
||||||
|
|
||||||
|
# pycharm fils
|
||||||
|
.idea/
|
||||||
|
.idea
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
PATH=$PATH:borg_interface/bin/
|
PATH=$PATH:borg_interface/bin/
|
||||||
source borg_interface/bin/activate
|
source borg_interface/bin/activate
|
||||||
python3 borg_interface/backup_to_fileserver.py
|
python3 borg_interface/backup_to_external.py
|
||||||
exit 0
|
exit 0
|
|
@ -1,5 +1,5 @@
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
#server: fileserver.2li.local
|
server: fileserver.2li.local
|
||||||
#user: borg
|
user: borg
|
||||||
repository_path: /home/andreas/test
|
repository_path: /home/borg/backup/gwyn
|
||||||
password: foo
|
password: 7EMvQ9G4ay7woHXSS5Dt27eZDsnDZu
|
||||||
|
|
|
@ -10,17 +10,24 @@ int_vars = interface_variables
|
||||||
|
|
||||||
|
|
||||||
def take_backup():
|
def take_backup():
|
||||||
response = subprocess.Popen(['ping', '-c', '1', 'fileserver.2li.local'])
|
response = subprocess.Popen(['ping', '-c', '1', 'fileserver.2li.local'],
|
||||||
|
stdout=subprocess.PIPE)
|
||||||
response.wait()
|
response.wait()
|
||||||
returncode = response.returncode
|
returncode = response.returncode
|
||||||
if returncode == 0:
|
if returncode == 0:
|
||||||
backup_home()
|
backup_home()
|
||||||
|
print()
|
||||||
|
print()
|
||||||
backup_vms()
|
backup_vms()
|
||||||
|
print()
|
||||||
|
print()
|
||||||
prune_home()
|
prune_home()
|
||||||
|
print()
|
||||||
|
print()
|
||||||
prune_vms()
|
prune_vms()
|
||||||
else:
|
else:
|
||||||
print("Server not available")
|
print("Server not available")
|
||||||
sys.exit(0)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def backup_home():
|
def backup_home():
|
||||||
|
@ -28,7 +35,9 @@ def backup_home():
|
||||||
archive_name = (socket.gethostname() + "-home"
|
archive_name = (socket.gethostname() + "-home"
|
||||||
+ time.strftime("_%Y-%m-%d_%H:%M"))
|
+ time.strftime("_%Y-%m-%d_%H:%M"))
|
||||||
|
|
||||||
p = subprocess.Popen(['borg', 'create', '--exclude', '/home/andreas/.cache',
|
print("Backup " + archive_name)
|
||||||
|
p = subprocess.Popen(['borg', 'create', '-v', '--stats', '--exclude',
|
||||||
|
'/home/andreas/.cache',
|
||||||
'--exclude', '/home/andreas/Downloads',
|
'--exclude', '/home/andreas/Downloads',
|
||||||
'::' + archive_name, path_to_backup])
|
'::' + archive_name, path_to_backup])
|
||||||
p.wait()
|
p.wait()
|
||||||
|
@ -39,14 +48,17 @@ def backup_vms():
|
||||||
archive_name = (socket.gethostname() + "-VMs"
|
archive_name = (socket.gethostname() + "-VMs"
|
||||||
+ time.strftime("_%Y-%m-%d_%H:%M"))
|
+ time.strftime("_%Y-%m-%d_%H:%M"))
|
||||||
|
|
||||||
p = subprocess.Popen(['borg', 'create',
|
print("Backup " + archive_name)
|
||||||
|
p = subprocess.Popen(['borg', 'create', '-v', '--stats',
|
||||||
'::' + archive_name, path_to_backup])
|
'::' + archive_name, path_to_backup])
|
||||||
p.wait()
|
p.wait()
|
||||||
|
|
||||||
|
|
||||||
def prune_home():
|
def prune_home():
|
||||||
archive_name = (socket.gethostname() + "-home")
|
archive_name = (socket.gethostname() + "-home")
|
||||||
p = subprocess.Popen(['borg', 'prune', '--prefix', archive_name,
|
print("Prune " + archive_name)
|
||||||
|
p = subprocess.Popen(['borg', 'prune', '-v', '--stats', '--prefix',
|
||||||
|
archive_name,
|
||||||
'--keep-hourly=24', '--keep-daily=7',
|
'--keep-hourly=24', '--keep-daily=7',
|
||||||
'--keep-weekly=4', '--keep-monthly=12',
|
'--keep-weekly=4', '--keep-monthly=12',
|
||||||
'--keep-yearly=1'])
|
'--keep-yearly=1'])
|
||||||
|
@ -55,7 +67,9 @@ def prune_home():
|
||||||
|
|
||||||
def prune_vms():
|
def prune_vms():
|
||||||
archive_name = (socket.gethostname() + "-VMs")
|
archive_name = (socket.gethostname() + "-VMs")
|
||||||
p = subprocess.Popen(['borg', 'prune', '--prefix', archive_name,
|
print("Prune " + archive_name)
|
||||||
|
p = subprocess.Popen(['borg', 'prune', '-v', '--stats', '--prefix',
|
||||||
|
archive_name,
|
||||||
'--keep-hourly=24', '--keep-daily=7',
|
'--keep-hourly=24', '--keep-daily=7',
|
||||||
'--keep-weekly=4', '--keep-monthly=12',
|
'--keep-weekly=4', '--keep-monthly=12',
|
||||||
'--keep-yearly=1'])
|
'--keep-yearly=1'])
|
|
@ -124,7 +124,7 @@ def configuration():
|
||||||
config.read(config_file)
|
config.read(config_file)
|
||||||
else:
|
else:
|
||||||
print("Configuration file not found.")
|
print("Configuration file not found.")
|
||||||
sys.exit(0)
|
sys.exit(1)
|
||||||
# assign the repository variable depending whether it's a remote or a local
|
# assign the repository variable depending whether it's a remote or a local
|
||||||
# repository
|
# repository
|
||||||
if 'server' in config['DEFAULT']:
|
if 'server' in config['DEFAULT']:
|
||||||
|
|
Reference in New Issue