mirror of
https://codeberg.org/tmayoff/.dotfiles.git
synced 2025-12-06 08:48:34 -05:00
Initial Commit
This commit is contained in:
commit
e726aebd5b
22 changed files with 1098 additions and 0 deletions
41
private_dot_local/bin/executable_,daily_backup
Normal file
41
private_dot_local/bin/executable_,daily_backup
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#!/bin/env fish
|
||||
|
||||
set current_date $(date +%Y-%m-%d)
|
||||
|
||||
set log_dir "$XDG_STATE_HOME/logs/backups"
|
||||
set log_file "$log_dir/backup_$current_date.log"
|
||||
|
||||
set last $(restic snapshots | tail -3 | head -1 | awk '{print $2}')
|
||||
if test $status != 0
|
||||
echo "can't find last snapshot" | tee -a $log_file
|
||||
notify-send -a "backup" "Failed to get last snapshot for backups" -u critical
|
||||
exit $status
|
||||
end
|
||||
|
||||
function exit_handler
|
||||
# Restore std...
|
||||
# exec 2>&4 1>&3
|
||||
end
|
||||
|
||||
# Setup logging
|
||||
mkdir -p $log_dir || true
|
||||
|
||||
trap exit_handler 0 1 2 3
|
||||
|
||||
printf "Current date: %s. Last snapshot: %s\n" $current_date $last | tee -a $log_file
|
||||
|
||||
if test "$last" != "$current_date"
|
||||
set not_id $(notify-send -a "backup" "Daily backup $current_date started." -p)
|
||||
restic backup -v "$HOME" --exclude-file "$XDG_CONFIG_HOME/restic/ignore" | tee -a $log_file
|
||||
if test $status != 0
|
||||
echo "Backup failed." | tee -a $log_file
|
||||
notify-send -a "backup" "Backup $current_date failed!" -u critical -r $not_id
|
||||
exit $status
|
||||
end
|
||||
|
||||
printf "Backup success\n." | tee -a $log_file
|
||||
|
||||
notify-send -a "backup" "Daily backup $current_date succeeded." -r $not_id
|
||||
else
|
||||
printf "No backup needed" | tee -a $log_file
|
||||
end
|
||||
6
private_dot_local/bin/executable_,git-prune
Normal file
6
private_dot_local/bin/executable_,git-prune
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
echo "Cleaning remote branches"
|
||||
git remote prune origin
|
||||
echo "Cleaning local branches"
|
||||
git for-each-ref --format '%(refname:short)' refs/heads | grep -v master | xargs git branch -D
|
||||
5
private_dot_local/bin/executable_,restic-backup.sh
Normal file
5
private_dot_local/bin/executable_,restic-backup.sh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
restic backup "$HOME" --exclude-file "$XDG_CONFIG_HOME"/restic/ignore --exclude-caches
|
||||
restic unlock
|
||||
restic forget --keep-daily 7 --keep-weekly 4 --prune
|
||||
4
private_dot_local/bin/executable_,restic-lastbackup.sh
Normal file
4
private_dot_local/bin/executable_,restic-lastbackup.sh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
restic snapshots | tail -3 | head -1 | awk '{print "Last backup: " $2 " " $3}'
|
||||
restic check
|
||||
10
private_dot_local/bin/executable_,yupdate.fish
Normal file
10
private_dot_local/bin/executable_,yupdate.fish
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env fish
|
||||
|
||||
yadm pull
|
||||
|
||||
pushd $HOME/.local/share/yadm/repo.git
|
||||
git-forgit add
|
||||
yadm commit
|
||||
popd
|
||||
|
||||
yadm push
|
||||
Loading…
Add table
Add a link
Reference in a new issue