Bunch of changes; renaming the ConfigBackup; you kinda suck
This commit is contained in:
23
Kumonoboru
23
Kumonoboru
@@ -1,7 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
##Simple script to run Restic backups
|
##Simple script to run Restic backups
|
||||||
source $SCRIPTS/Okiru
|
source /root/.bash_profile
|
||||||
|
source /home/shmick/Scripts/Okiru
|
||||||
source /etc/environment
|
source /etc/environment
|
||||||
|
export HOME=/root/
|
||||||
arg0=$(basename "$0")
|
arg0=$(basename "$0")
|
||||||
#Show help if arguments are misused
|
#Show help if arguments are misused
|
||||||
usage()
|
usage()
|
||||||
@@ -26,9 +28,9 @@ help()
|
|||||||
echo " {-l|--limit} #[Kbps] -- Limit upload & download speed"
|
echo " {-l|--limit} #[Kbps] -- Limit upload & download speed"
|
||||||
echo " {-h|--help} -- Print this help message and exit"
|
echo " {-h|--help} -- Print this help message and exit"
|
||||||
echo "Available repositories:"
|
echo "Available repositories:"
|
||||||
echo "Gerbil-TK Photos (path: /Red-Vol/Media/Pictures)"
|
echo "Gerbil-TK Photos (path: /var/Red-Vol/Media/Pictures)"
|
||||||
echo "Pukeko-XYZ-Containers Containers (path: /Red-Vol/Media/Containers)"
|
echo "Pukeko-XYZ-Containers Containers (path: /var/Red-Vol/Media/Containers)"
|
||||||
echo "Pukeko-XYZ-Cloud Data from all devices (path: /Red-Vol/Media/Cloud/Syncthing)"
|
echo "Pukeko-XYZ-Cloud Data from all devices (path: /var/Red-Vol/Media/Cloud/Syncthing)"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
#Pass arguments to the script
|
#Pass arguments to the script
|
||||||
@@ -135,22 +137,22 @@ clean(){
|
|||||||
if [[ -n $REPOSITORY ]] && [[ -z $CLEAN ]]; then
|
if [[ -n $REPOSITORY ]] && [[ -z $CLEAN ]]; then
|
||||||
case "$REPOSITORY" in
|
case "$REPOSITORY" in
|
||||||
(Gerbil-TK)
|
(Gerbil-TK)
|
||||||
backup Gerbil-TK /Red-Vol/Media/Pictures/
|
backup Gerbil-TK /var/Red-Vol/Media/Pictures/
|
||||||
;;
|
;;
|
||||||
(Pukeko-XYZ-Containers)
|
(Pukeko-XYZ-Containers)
|
||||||
backup Pukeko-XYZ-Containers /Red-Vol/Media/Containers
|
backup Pukeko-XYZ-Containers /var/Red-Vol/Media/Containers
|
||||||
;;
|
;;
|
||||||
(Pukeko-XYZ-Cloud)
|
(Pukeko-XYZ-Cloud)
|
||||||
backup Pukeko-XYZ-Cloud /Red-Vol/Media/Cloud/Syncthing
|
backup Pukeko-XYZ-Cloud /var/Red-Vol/Media/Cloud/Syncthing
|
||||||
;;
|
;;
|
||||||
(*)
|
(*)
|
||||||
help;;
|
help;;
|
||||||
esac
|
esac
|
||||||
#If cleaning was not forced, backup the repositories
|
#If cleaning was not forced, backup the repositories
|
||||||
elif [[ -z $CLEAN ]]; then
|
elif [[ -z $CLEAN ]]; then
|
||||||
backup Gerbil-TK /Red-Vol/Media/Pictures/
|
backup Gerbil-TK /var/Red-Vol/Media/Pictures/
|
||||||
backup Pukeko-XYZ-Containers /Red-Vol/Media/Containers
|
backup Pukeko-XYZ-Containers /var/Red-Vol/Media/Containers
|
||||||
backup Pukeko-XYZ-Cloud /Red-Vol/Media/Cloud/Syncthing
|
backup Pukeko-XYZ-Cloud /var/Red-Vol/Media/Cloud/Syncthing
|
||||||
#If a specific repository was requested to be cleaned, clean it
|
#If a specific repository was requested to be cleaned, clean it
|
||||||
elif [[ -n $REPOSITORY ]] && [[ -n $CLEAN ]]; then
|
elif [[ -n $REPOSITORY ]] && [[ -n $CLEAN ]]; then
|
||||||
case "$REPOSITORY" in
|
case "$REPOSITORY" in
|
||||||
@@ -174,3 +176,4 @@ elif [[ -n $CLEAN ]] || [[ $(date +%a) == "Friday" ]]; then
|
|||||||
fi
|
fi
|
||||||
#Wrap up this run's log and report nicely
|
#Wrap up this run's log and report nicely
|
||||||
end_logging
|
end_logging
|
||||||
|
exit 0
|
||||||
|
|||||||
@@ -39,14 +39,20 @@ elif [[ ! -f "$1" ]]; then
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
#Configuration files to sync
|
#Configuration files to sync
|
||||||
conf_sync /etc/ddclient.conf $CONF_DIR
|
conf_sync /etc/docker/daemon.json
|
||||||
for tab in $(ls /var/spool/cron/tabs/*); do
|
|
||||||
conf_sync $tab
|
|
||||||
done
|
|
||||||
conf_sync /etc/environment
|
conf_sync /etc/environment
|
||||||
|
conf_sync /etc/fstab
|
||||||
conf_sync /etc/hosts
|
conf_sync /etc/hosts
|
||||||
conf_sync /etc/postfix/main.cf
|
conf_sync /etc/postfix/main.cf
|
||||||
conf_sync /etc/anacrontab
|
conf_sync /etc/profile
|
||||||
|
for conf in $(ls /etc/snapper/configs/* 2> /dev/null); do
|
||||||
|
conf_sync $conf
|
||||||
|
done
|
||||||
|
for conf in $(ls /etc/systemd/system/murchison*); do
|
||||||
|
conf_sync $conf
|
||||||
|
done
|
||||||
|
for conf in $(ls /etc/systemd/system/kumonoboru*); do
|
||||||
|
conf_sync $conf
|
||||||
|
done
|
||||||
#Fix permissions
|
#Fix permissions
|
||||||
chown -R shmick $CONF_DIR
|
chown -R shmick $CONF_DIR
|
||||||
10
Okiru
10
Okiru
@@ -78,21 +78,21 @@ logging () {
|
|||||||
}
|
}
|
||||||
#Debugging level logging; can be toggled via a switch
|
#Debugging level logging; can be toggled via a switch
|
||||||
debug () {
|
debug () {
|
||||||
printf "${BLUE}[DEBUG]: $1${STOP}\n" > /dev/stdout
|
printf "${BLUE}[DEBUG]: $1${STOP}\n"
|
||||||
if [[ -f $LOG ]]; then
|
if [[ -f $LOG ]]; then
|
||||||
echo -e "$(date | awk '{print $4}') [DEBUG]: $1" >> $LOG
|
echo -e "$(date | awk '{print $4}') [DEBUG]: $1" >> $LOG
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
#Information level logging;
|
#Information level logging;
|
||||||
info () {
|
info () {
|
||||||
printf "${CYAN}[INFO]:${STOP} $1\n" > /dev/stdout
|
printf "${CYAN}[INFO]:${STOP} $1\n"
|
||||||
if [[ -f $LOG ]]; then
|
if [[ -f $LOG ]]; then
|
||||||
echo -e "$(date | awk '{print $4}') [INFO]: $1" >> $LOG
|
echo -e "$(date | awk '{print $4}') [INFO]: $1" >> $LOG
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
#Warning level logging;
|
#Warning level logging;
|
||||||
warn () {
|
warn () {
|
||||||
printf "${YELLOW}[WARNING]:${STOP} $1\n" > /dev/stdout
|
printf "${YELLOW}[WARNING]:${STOP} $1\n"
|
||||||
if [[ -f $LOG ]]; then
|
if [[ -f $LOG ]]; then
|
||||||
echo -e "$(date | awk '{print $4}') [WARN]: $1" >> $LOG
|
echo -e "$(date | awk '{print $4}') [WARN]: $1" >> $LOG
|
||||||
fi
|
fi
|
||||||
@@ -101,7 +101,7 @@ warn () {
|
|||||||
error () {
|
error () {
|
||||||
echo $1 1>&2
|
echo $1 1>&2
|
||||||
# ` ^ Output error message to stderr
|
# ` ^ Output error message to stderr
|
||||||
printf "${RED}[ERROR]: $1${STOP}\n" > /dev/stdout
|
printf "${RED}[ERROR]: $1${STOP}\n"
|
||||||
# ^ Print it to the screen
|
# ^ Print it to the screen
|
||||||
errors+=("$1")
|
errors+=("$1")
|
||||||
# ^ And add to errors array
|
# ^ And add to errors array
|
||||||
@@ -116,7 +116,7 @@ error () {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
ok () {
|
ok () {
|
||||||
printf "${GREEN}[SUCCESS]: $1${STOP}\n" > /dev/stdout
|
printf "${GREEN}[SUCCESS]: $1${STOP}\n"
|
||||||
if [[ -f $LOG ]]; then
|
if [[ -f $LOG ]]; then
|
||||||
echo -e "$(date | awk '{print $4}') [SUCCESS]: $1" >> $LOG
|
echo -e "$(date | awk '{print $4}') [SUCCESS]: $1" >> $LOG
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -17,4 +17,4 @@ else
|
|||||||
# ^ If connection is established, use local DNS
|
# ^ If connection is established, use local DNS
|
||||||
fi
|
fi
|
||||||
#Force update of DNS resolution
|
#Force update of DNS resolution
|
||||||
netconfig update -f
|
/sbin/netconfig update -f
|
||||||
|
|||||||
Reference in New Issue
Block a user