]>
Commit | Line | Data |
---|---|---|
9f6a7862 IB |
1 | { pkgs }: |
2 | { | |
dded6699 | 3 | keepLastNDumps = ext: backupDir: n: '' |
9f6a7862 IB |
4 | #!${pkgs.stdenv.shell} |
5 | ||
6 | cd ${backupDir} | |
7 | ${pkgs.coreutils}/bin/rm -f \ | |
dded6699 | 8 | $(${pkgs.coreutils}/bin/ls -1 *.${ext} \ |
9f6a7862 IB |
9 | | ${pkgs.coreutils}/bin/sort -r \ |
10 | | ${pkgs.gnused}/bin/sed -e '1,${builtins.toString n}d') | |
11 | ''; | |
dded6699 | 12 | exponentialDumps = ext: backupDir: let |
9f6a7862 IB |
13 | log2rotateSrc = builtins.fetchGit { |
14 | url = "https://github.com/avian2/pylog2rotate"; | |
15 | ref = "master"; | |
16 | rev = "061f0564757289d3bea553b16f8fd5c4a0319c5e"; | |
17 | }; | |
18 | log2rotate = pkgs.writeScript "log2rotate" '' | |
19 | #!${pkgs.python3}/bin/python | |
20 | ||
21 | ${builtins.readFile "${log2rotateSrc}/log2rotate.py"} | |
22 | ''; | |
23 | in '' | |
24 | #!${pkgs.stdenv.shell} | |
25 | ||
26 | cd ${backupDir} | |
dded6699 IB |
27 | ${pkgs.coreutils}/bin/rm -f $(ls -1 *.${ext} | grep -v 'T22:' | sort -r | sed -e '1,12d') |
28 | ${pkgs.coreutils}/bin/rm -f $(ls -1 *T22*.${ext} | ${log2rotate} --skip 7 --fuzz 7 --delete --format='%Y-%m-%dT%H:%M:%S+00:00.${ext}') | |
9f6a7862 IB |
29 | ''; |
30 | } |