diff --git a/configure.ac b/configure.ac index 8cfd9d4c2..5937a704a 100644 --- a/configure.ac +++ b/configure.ac @@ -477,6 +477,14 @@ src/nhttpd/nhttpd.conf #data/control/migration.sh #]) +# Backup scripts +AC_CONFIG_FILES([ +data/scripts/backup.sh +data/scripts/restore.sh +data/scripts/backup_flash.sh +data/scripts/restore_flash.sh +]) + # Backup configs AC_CONFIG_FILES([ data/config/settingsupdate.conf diff --git a/data/config/settingsupdate.conf.in b/data/config/settingsupdate.conf.in index d2e6b2313..c49aa7e3a 100644 --- a/data/config/settingsupdate.conf.in +++ b/data/config/settingsupdate.conf.in @@ -32,13 +32,41 @@ #------------- ## Sicherungen #------------- -@CONFIGDIR@/ +@CONFIGDIR@/tobackup.conf +@CONFIGDIR@/settingsupdate.conf + +@CONFIGDIR@/cables.xml +# +# +#@CONFIGDIR@/FritzCallMonitor.cfg +@CONFIGDIR@/radio-favorites.xml +@CONFIGDIR@/radio-stations.xml +@CONFIGDIR@/timerd.conf +@CONFIGDIR@/satellites.xml +@CONFIGDIR@/tuxcal/ +@CONFIGDIR@/tuxmail/ +@CONFIGDIR@/zapit/ +# +# +@CONFIGDIR@/scan.conf +# +# +@FLAGDIR@/ + +#/var/bin/ +# +#/var/log/ +#/var/root/ +#/var/xupnpd/ /etc/exports /etc/hostname /etc/hosts +# /etc/passwd +# /etc/resolv.conf +/etc/samba/smb.conf /etc/wpa_supplicant.conf @@ -48,11 +76,11 @@ #---------------------------------------------------------------------------------------- ## von der Sicherung auszuschließende Dateien, gekennzeichnet durch ein vorangestelltes - #---------------------------------------------------------------------------------------- --/var/etc/update.urls --@CONFIGDIR@/cables.xml --@CONFIGDIR@/encoding.conf --@CONFIGDIR@/providermap.xml --@CONFIGDIR@/radio-stations.xml --@CONFIGDIR@/satellites.xml --@CONFIGDIR@/settingsupdate.conf --@CONFIGDIR@/tobackup.conf +#-/var/etc/update.urls +#-@CONFIGDIR@/cables.xml +#-@CONFIGDIR@/encoding.conf +#-@CONFIGDIR@/providermap.xml +#-@CONFIGDIR@/radio-stations.xml +#-@CONFIGDIR@/satellites.xml +#-@CONFIGDIR@/settingsupdate.conf +#-@CONFIGDIR@/tobackup.conf diff --git a/data/scripts/Makefile.am b/data/scripts/Makefile.am index fc94aed56..3e79da17d 100644 --- a/data/scripts/Makefile.am +++ b/data/scripts/Makefile.am @@ -1,3 +1,9 @@ +EXTRA_DIST = \ + backup.sh backup.sh.in \ + restore.sh restore.sh.in \ + backup_flash.sh backup_flash.sh.in \ + restore_flash.sh restore_flash.sh.in + installdir = $(bindir) install_SCRIPTS = \ diff --git a/data/scripts/backup.sh b/data/scripts/backup.sh.in old mode 100755 new mode 100644 similarity index 86% rename from data/scripts/backup.sh rename to data/scripts/backup.sh.in index 98f7c57dd..4f8fd098c --- a/data/scripts/backup.sh +++ b/data/scripts/backup.sh.in @@ -4,7 +4,7 @@ HOST=$(hostname) DATE=$(date +%Y%m%d_%H%M) -USRF="/var/tuxbox/config/tobackup.conf" +USRF="@CONFIGDIR@/tobackup.conf" BAKF="$1/${2:-settings_${HOST}_${DATE}}.tar.gz" if [ -e "${USRF}" ]; then @@ -15,7 +15,7 @@ if [ -e "${USRF}" ]; then done < $USRF else - TOBACKUP="/var/tuxbox/config/" + TOBACKUP="@CONFIGDIR@/" fi # check existence diff --git a/data/scripts/backup_flash.sh.in b/data/scripts/backup_flash.sh.in new file mode 100644 index 000000000..de2dec156 --- /dev/null +++ b/data/scripts/backup_flash.sh.in @@ -0,0 +1,35 @@ +#!/bin/sh + +. /etc/init.d/globals + +RES="" +VAR="/var/" +USRF="@CONFIGDIR@/tobackup.conf" +BAKF="/var/backup_flash.tar.gz" + +TOBACKUP="" + +SHOWINFO "backup to ${BAKF} ..." + +if [ -e "${USRF}" ]; then + TOBACKUP="$TOBACKUP ${USRF}" + while read i + do [ "${i:0:1}" = "#" ] || TOBACKUP="$TOBACKUP ${i%%#*}" + done < $USRF +fi + +# check existence and skip files in /var +for i in $TOBACKUP; do + if [ -e "$i" -a ${i:0:${#VAR}} != ${VAR} ]; then + SHOWINFO "add $i" + RES="$RES $i" + else + SHOWINFO "skip $i" + fi +done + +TOBACKUP=$(echo $RES) + +tar -czf "${BAKF}" $TOBACKUP 2>&1 >/dev/null + +SHOWINFO "done." diff --git a/data/scripts/restore.sh b/data/scripts/restore.sh.in similarity index 100% rename from data/scripts/restore.sh rename to data/scripts/restore.sh.in diff --git a/data/scripts/restore_flash.sh.in b/data/scripts/restore_flash.sh.in new file mode 100644 index 000000000..a6bc9a4e2 --- /dev/null +++ b/data/scripts/restore_flash.sh.in @@ -0,0 +1,15 @@ +#!/bin/sh + +. /etc/init.d/globals + +BAKF="/var/backup_flash.tar.gz" + +if [ -e ${BAKF} ]; then + SHOWINFO "restore settings from ${BAKF} ..." + cd / && tar -xzf "${BAKF}" + sync + rm -rf "${BAKF}" + SHOWINFO "done." +else + SHOWINFO "${BAKF} not found. nothing to restore!" +fi