Initial code commit
This commit is contained in:
parent
c8a14414ad
commit
c721144f75
1
.gitignore
vendored
1
.gitignore
vendored
@ -160,3 +160,4 @@ cython_debug/
|
|||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
|
src/config.py
|
3
src/example_config.py
Normal file
3
src/example_config.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
PWD_URL = "https://my-domain/ABunchOfRandomCharactersBecauseThisIsNotReallyImportant.file"
|
||||||
|
DISK = "/dev/sda"
|
||||||
|
MNT_LOCATION = "/mnt"
|
39
src/main.py
Normal file
39
src/main.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
import subprocess
|
||||||
|
import requests
|
||||||
|
import os
|
||||||
|
|
||||||
|
from . import config
|
||||||
|
|
||||||
|
def log(*args, **kwargs):
|
||||||
|
date = datetime.now().strftime('%d-%b-%Y %H:%M:%S')
|
||||||
|
print(f"[{date}]", *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
if not os.path.exists(config.DISK):
|
||||||
|
log_error(f"Drive {config.DISK} not present on the system")
|
||||||
|
|
||||||
|
passwd = requests.get(config.PWD_URL).text
|
||||||
|
log("Got password :", passwd)
|
||||||
|
|
||||||
|
subprocess.call([
|
||||||
|
"cryptsetup", "luksOpen",
|
||||||
|
"--key-description", passwd,
|
||||||
|
config.DISK, "backup"
|
||||||
|
])
|
||||||
|
|
||||||
|
subprocess.call([
|
||||||
|
"mount", "/dev/mapper/backup",
|
||||||
|
config.MNT_LOCATION
|
||||||
|
])
|
||||||
|
|
||||||
|
log("Succesfully mounted, doing the backup stuff")
|
||||||
|
|
||||||
|
subprocess.call([
|
||||||
|
"umount", config.MNT_LOCATION
|
||||||
|
])
|
||||||
|
|
||||||
|
subprocess.call([
|
||||||
|
"cryptsetup", "luksClose",
|
||||||
|
"/dev/mapper/backup"
|
||||||
|
])
|
Loading…
Reference in New Issue
Block a user