mirror of
https://github.com/Derisis13/barusu.git
synced 2025-12-07 03:52:48 +01:00
-d and --backup-dir options completed
This commit is contained in:
15
main.py
15
main.py
@@ -31,35 +31,36 @@ def save_settings():
|
||||
|
||||
|
||||
def restore():
|
||||
# todo
|
||||
return # todo
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
backupdir = "/home/lacko/.backup"
|
||||
backupdir = os.path.expanduser("~/.backup")
|
||||
try:
|
||||
options, values = getopt.getopt(sys.argv[1:], "hd:r", ["help", "backup-dir=", "restore"])
|
||||
except getopt.GetoptError as err:
|
||||
print("Error: ", err.msg)
|
||||
exit(1)
|
||||
for option, value in options:
|
||||
if option in ("h", "help"):
|
||||
if option in ("-h", "help"):
|
||||
print("usage: <name> [opts]\n\
|
||||
Options:\n\
|
||||
\t-h --help: show this\n\
|
||||
\t-d --backup-dir [directory]: set the directory for the backup/restoration (default is ~/.backups)\n\
|
||||
\t-r --restore: run the restoration (from backupdir)\n") # todo: <name>
|
||||
exit()
|
||||
elif option in("d", "backup-dir"):
|
||||
backupdir = value
|
||||
elif option in("r", "restore"):
|
||||
elif option in ("-d", "backup-dir"):
|
||||
backupdir = os.path.expanduser(value)
|
||||
elif option in ("-r", "restore"):
|
||||
restore()
|
||||
exit()
|
||||
|
||||
try:
|
||||
# os.chdir("/run/user/1000/gvfs/smb-share:server=ds_panni.local,share=lacko/Backup/T490")
|
||||
os.chdir(backupdir)
|
||||
except FileNotFoundError:
|
||||
subprocess.call(["mkdir", backupdir])
|
||||
os.chdir(backupdir)
|
||||
|
||||
run_daily()
|
||||
list_pkgs()
|
||||
save_settings()
|
||||
|
||||
Reference in New Issue
Block a user