Files
sld-filebackups-py/script.py

32 lines
1.1 KiB
Python
Executable File

#!/bin/python3
import argparse
# configure logging first (logger reads config.json located next to this file)
from logger import setup_logger
setup_logger()
import logging
# ora importiamo le funzioni (che useranno logging invece di print)
from functions import *
default_backup_dir()
parser = argparse.ArgumentParser(description="Backup script")
parser.add_argument("-s", "--show", action="store_true", help="Show enabled paths")
parser.add_argument("-d", "--debug", action="store_true", help="Enable debug")
parser.add_argument("-c", "--check", action="store_true", help="Check the declared path info")
parser.add_argument("-r", "--rotate", action="store_true", help="Rotate the backups")
parser.add_argument("--dry", action="store_true", help="Dry run for rotate: show what would be deleted (no deletion)")
args = parser.parse_args()
if args.show:
show_enabled()
elif args.debug:
backups_now(debug="on")
elif args.check:
checked = check_existing_folders(debug="on")
elif args.rotate:
autorotate_backups(dry_run=args.dry)
else:
backups_now()
autorotate_backups()