aboutsummaryrefslogtreecommitdiff
path: root/config/i3blocks/scripts/backup
blob: bfa3d3992bf76fa1bac99ff0bf1850d88e8f1eda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash

if [[ -n "$BLOCK_BUTTON" ]]; then
	nohup urxvt -title "System backup" -hold -e sudo system-backup 2>&1 >/dev/null &
fi

state=5
if [[ -e ~/.backup_date ]]; then
	now=$(date +"%s")
	prev=$(cat ~/.backup_date)
	dif=$(expr $now - $prev)
	# 15 days
	if [[ $dif -ge 648000 ]]; then
		state=4
	# 12 days
	elif [[ $dif -ge 518400 ]]; then
		state=3
	# 5 days
	elif [[ $dif -ge 216000 ]]; then
		state=2
	# 2 days
	elif [[ $dif -ge 86400 ]]; then
		state=1
	else
		state=0
	fi
fi

if [[ $state -eq 0 ]]; then
	exit 0
fi

echo "Do backup"
echo "Backup"
case $state in
	1)
		echo
		;;
	2)
		echo "#ffff00"
		;;
	3)
		echo "#ff8a00"
		;;
	4)
		echo "#ff5000"
		;;
	5)
		echo "#ff0000"
		;;
esac