move borg_interface out of this repository.

This project is getting too big for this repository. I've created a
seperate repository at https://git.2li.ch/Nebucatnetzer/borg_interface
This commit is contained in:
Andreas Zweili 2016-12-13 19:30:00 +01:00
parent e93f6a610a
commit 7edef0bd9c
3 changed files with 0 additions and 100 deletions

View File

@ -1,12 +0,0 @@
.idea
__pycache__
# swap
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
# session
Session.vim
# temporary
.netrwhist
*~
# auto-generated tag files
tags

View File

@ -1,5 +0,0 @@
[DEFAULT]
server: fileserver.2li.local
user: borg
repository_path: /home/borg/backup/gwyn
password: iEw74xjem7gvsJrShCVCbYrAwX7yUo

View File

@ -1,83 +0,0 @@
#!/usr/bin/env python3
import os
import sys
import configparser
import subprocess
chosen_activity = None
mount_point = None
# setup the config parser
config = configparser.ConfigParser()
# read config file
config.read('borg_interface.cfg')
# assign the repository variable
if 'server' in config:
repository = (config['DEFAULT']['user']
+ "@"
+ config['DEFAULT']['server']
+ ":"
+ config['DEFAULT']['repository_path'])
else:
repository = config['DEFAULT']['repository_path']
# assign the password variable
password = config['DEFAULT']['password']
# set the environment variables
os.environ['BORG_REPO'] = repository
os.environ['BORG_PASSPHRASE'] = password
# The main menu starts there
while chosen_activity != 0:
print("What would you like to do?")
# Start the chosen activity and go back to the activity selector.
print("1: List Backups, 2: Show archive details, 3: Mount Archive, "
"4: Restore Backup, 0: Exit")
try:
chosen_activity = int(input("Choose the desired activity: "))
if chosen_activity == 1:
# prints all the archives in the repository and lists them with
# less
os.system('borg list | less')
if chosen_activity == 2:
# Displays all the information related to the archive name the user
# enters
archive_name = input("Please enter the archive name: ")
os.system('borg info ::' + archive_name)
if chosen_activity == 3:
# mounts a chosen archive to /tmp/archive name
archive_name = input("Please enter the archive name: ")
mount_point = "/tmp/" + archive_name
if not os.path.exists(mount_point):
os.makedirs(mount_point)
os.system('borg mount ::' + archive_name + " " + mount_point)
print()
print("Archive mounted at " + mount_point + "/")
print()
if chosen_activity == 4:
archive_name = input("Please enter the archive name: ")
restore_path = input("Please enter the path where you want to "
"restore to: ")
working_directory = os.system('pwd')
if not os.path.exists(restore_path):
os.makedirs(restore_path)
p = subprocess.Popen(['borg', 'extract', ':: + archive_name],
cwd=restore_path)
p.wait()
print()
print("Archive extracted to " + restore_path)
print()
elif chosen_activity == 0:
if (not mount_point):
print()
else:
print()
print("Unmount Archive and remove folder.")
print()
os.system('fusermount -u' + " " + mount_point)
os.rmdir(mount_point)
except ValueError:
print("Please enter a full number.")