Add stat section to backup pacman hook to avoid doing it more that once a day
This commit is contained in:
parent
0c78a23025
commit
8e714b29fe
3 changed files with 24 additions and 1 deletions
|
@ -1,5 +1,17 @@
|
|||
#!/bin/sh
|
||||
|
||||
# We only want this file to be executed at most once per day, so we stat a cache
|
||||
# file before running the rest of the code
|
||||
cache_file='/home/flyingscorpio/.cache/borg_backup_hood_last_executed'
|
||||
if [ -f "$cache_file" ]; then
|
||||
cache_stat=$(stat -c %y "$cache_file" | cut -d' ' -f1)
|
||||
today=$(date +%Y-%m-%d)
|
||||
if [ "$cache_stat" = "$today" ]; then
|
||||
echo "The borg backup was already executed today" && exit 0
|
||||
fi
|
||||
fi
|
||||
touch "$cache_file"
|
||||
|
||||
# Setting this so the repo does not need to be given on the command line:
|
||||
BORG_REPO=ssh://flyingscorpio@2px.info:22/~/"$(hostname)".borg
|
||||
export BORG_REPO
|
|
@ -8,5 +8,5 @@ Target = *
|
|||
[Action]
|
||||
Description = Run an update_to_lime2 script before every pacman transaction
|
||||
When = PreTransaction
|
||||
Exec = /bin/sh /home/flyingscorpio/SetupCockpit/arch-desktop_borg.sh
|
||||
Exec = /bin/sh /home/flyingscorpio/SetupCockpit/pacman_hooks/arch-desktop_borg.sh
|
||||
Depends = borg
|
11
pacman_hooks/new_orphan.hook
Normal file
11
pacman_hooks/new_orphan.hook
Normal file
|
@ -0,0 +1,11 @@
|
|||
[Trigger]
|
||||
Operation = Install
|
||||
Operation = Upgrade
|
||||
Operation = Remove
|
||||
Type = Package
|
||||
Target = *
|
||||
|
||||
[Action]
|
||||
Description = Notify if a transaction orphaned a package
|
||||
When = PostTransaction
|
||||
Exec = /usr/bin/bash -c "/usr/bin/pacman -Qtd || /usr/bin/echo '=> None found.'"
|
Loading…
Add table
Reference in a new issue