Browse Source

Put hostname in front for backup filename and pad number with zeros

master
Raphael Roberts 5 years ago
parent
commit
35613ce009
  1. 4
      openwrt_backup/config.py
  2. 5
      openwrt_backup/utils.py

4
openwrt_backup/config.py

@ -18,8 +18,8 @@ CACHE_DIR = ensure_directory_exists(appdirs.user_cache_dir)
CONFIG_FILE_PATH = CONFIG_DIR / "config.toml"
PACKAGE_ROOT = Path(__file__).absolute().parent
HOSTNAME = 1
NUMBER = 0
HOSTNAME = 0
NUMBER = 1
if not CONFIG_FILE_PATH.exists():
shutil.copy(PACKAGE_ROOT / "config.toml", CONFIG_FILE_PATH)

5
openwrt_backup/utils.py

@ -72,4 +72,7 @@ def get_next_number(backup_path: Path, hostname):
def get_new_backup_filepath(backup_path: Path, time_format, hostname):
next_number = get_next_number(backup_path, hostname)
dt = datetime.datetime.today()
return backup_path / f"{next_number}__{hostname}__{dt.strftime(time_format)}.tar.gz"
return (
backup_path
/ f"{hostname}__{next_number:03d}__{dt.strftime(time_format)}.tar.gz"
)
Loading…
Cancel
Save