diff --git a/README.md b/README.md index bfcda41..31c4037 100644 --- a/README.md +++ b/README.md @@ -162,6 +162,19 @@ To run the server component on Synology DSM, you need to install the following p * `openssh-sftp-server` * `util-linux-ng` +If you want to run your backups in a chroot environment please note that `/etc/fstab/` will be reset to its defaults when rebooting the disk station. To avoid configuration loss, no mount directives are added to `/etc/fstab` by the install script. Instead the following entries are added to `/etc/rc` (which won't be overwritten upon reboot): + + # BEGIN: rs-backup-suite + #mount -o bind /lib /var/services/homes/lib + #mount -o bind /dev /var/services/homes/dev + #mount -o bind /usr/bin /var/services/homes/usr/bin + #mount -o bind /opt/bin /var/services/homes/opt/bin + #mount -o bind /opt/lib /var/services/homes/opt/lib + #mount -o bind /opt/libexec /var/services/homes/opt/libexec + # END: rs-backup-suite + +To enable the mounts, uncomment everything between the `BEGIN` and `END` block. Afterwards either run these commands by hand once or reboot. + ### Cygwin The server component is incompatible with Cygwin for several reasons, but the client component works just fine. At the moment, though, there is no root mode for backing up all home directories at once. Desktop notifications are also unsupported. diff --git a/install.sh b/install.sh index 812668c..6f41bb8 100755 --- a/install.sh +++ b/install.sh @@ -142,16 +142,30 @@ if [[ $MODE == "install" ]]; then fi # Append fstab entries - if ! grep -q "^# BEGIN: rs-backup-suite" /etc/fstab; then - if [[ "$DISTRIBUTION" == "Ubuntu" ]]; then - fstab_name="fstab_ubuntu" - elif [[ "$DISTRIBUTION" == "Synology" ]]; then - fstab_name="fstab_synology" - else - fstab_name="fstab" + if [[ "$DISTRIBUTION" == "Synology" ]]; then + # Synology DSM restores default /etc/fstab upon reboot, + # so we better put mount commands in /etc/rc + if ! grep -q "^# BEGIN: rs-backup-suite" /etc/rc; then + tmp_name="/tmp/rs-backup_etc-rc.$RANDOM" + fstab_contents="$(cat ./server/etc/fstab_synology | sed "s#::BACKUP_ROOT::#$BKP_DIR#")" + tac /etc/rc | sed -e '1!b' -e '/^exit 0$/d' | tac > $tmp_name + echo "$fstab_contents" >> $tmp_name + echo "exit 0" >> $tmp_name + cat $tmp_name > /etc/rc + rm $tmp_name + fi + else + if ! grep -q "^# BEGIN: rs-backup-suite" /etc/fstab; then + if [[ "$DISTRIBUTION" == "Ubuntu" ]]; then + fstab_local_name="fstab_ubuntu" + elif [[ "$DISTRIBUTION" == "Synology" ]]; then + fstab_local_name="fstab_synology" + else + fstab_local_name="fstab" + fi + fstab_contents="$(cat ./server/etc/$fstab_local_name | sed "s#::BACKUP_ROOT::#$BKP_DIR#")" + echo "$fstab_contents" >> /etc/fstab fi - fstab_contents="$(cat ./server/etc/$fstab_name | sed "s#::BACKUP_ROOT::#$BKP_DIR#")" - echo "$fstab_contents" >> /etc/fstab fi # Do not overwrite existing config @@ -238,7 +252,11 @@ elif [[ "$MODE" == "uninstall" ]]; then fi # Remove fstab entries - sed -i '/^# BEGIN: rs-backup-suite$/,/^# END: rs-backup-suite$/d' /etc/fstab + fstab_name="/etc/fstab" + if [[ "$DISTRIBUTION" == "Synology" ]]; then + fstab_name="/etc/rc" + fi + sed -i '/^# BEGIN: rs-backup-suite$/,/^# END: rs-backup-suite$/d' $fstab_name echo "Done." diff --git a/server/etc/fstab b/server/etc/fstab index 0bf31a2..eafd4f3 100644 --- a/server/etc/fstab +++ b/server/etc/fstab @@ -1,7 +1,7 @@ # BEGIN: rs-backup-suite -#/lib ::BACKUP_ROOT::/lib none bind 0 0 -#/dev ::BACKUP_ROOT::/dev none bind 0 0 -#/usr/bin ::BACKUP_ROOT::/usr/bin none bind 0 0 -#/usr/lib ::BACKUP_ROOT::/usr/lib none bind 0 0 -#/usr/share/perl5 ::BACKUP_ROOT::/usr/share/perl5 none bind 0 0 +#/lib ::BACKUP_ROOT::/lib none bind 0 0 +#/dev ::BACKUP_ROOT::/dev none bind 0 0 +#/usr/bin ::BACKUP_ROOT::/usr/bin none bind 0 0 +#/usr/lib ::BACKUP_ROOT::/usr/lib none bind 0 0 +#/usr/share/perl5 ::BACKUP_ROOT::/usr/share/perl5 none bind 0 0 # END: rs-backup-suite diff --git a/server/etc/fstab_synology b/server/etc/fstab_synology index 840d394..94bf5e3 100644 --- a/server/etc/fstab_synology +++ b/server/etc/fstab_synology @@ -1,8 +1,8 @@ # BEGIN: rs-backup-suite -#/lib ::BACKUP_ROOT::/lib none bind 0 0 -#/dev ::BACKUP_ROOT::/dev none bind 0 0 -#/usr/bin ::BACKUP_ROOT::/usr/bin none bind 0 0 -#/opt/bin ::BACKUP_ROOT::/opt/bin none bind 0 0 -#/opt/lib ::BACKUP_ROOT::/opt/lib none bind 0 0 -#/opt/libexec ::BACKUP_ROOT::/opt/libexec none bind 0 0 +#mount -o bind /lib ::BACKUP_ROOT::/lib +#mount -o bind /dev ::BACKUP_ROOT::/dev +#mount -o bind /usr/bin ::BACKUP_ROOT::/usr/bin +#mount -o bind /opt/bin ::BACKUP_ROOT::/opt/bin +#mount -o bind /opt/lib ::BACKUP_ROOT::/opt/lib +#mount -o bind /opt/libexec ::BACKUP_ROOT::/opt/libexec # END: rs-backup-suite diff --git a/server/etc/fstab_ubuntu b/server/etc/fstab_ubuntu index 09d47ce..b6f83ff 100644 --- a/server/etc/fstab_ubuntu +++ b/server/etc/fstab_ubuntu @@ -1,7 +1,7 @@ # BEGIN: rs-backup-suite -#/lib ::BACKUP_ROOT::/lib none bind 0 0 -#/dev ::BACKUP_ROOT::/dev none bind 0 0 -#/usr/bin ::BACKUP_ROOT::/usr/bin none bind 0 0 -#/usr/lib ::BACKUP_ROOT::/usr/lib none bind 0 0 -#/usr/share/perl ::BACKUP_ROOT::/usr/share/perl none bind 0 0 +#/lib ::BACKUP_ROOT::/lib none bind 0 0 +#/dev ::BACKUP_ROOT::/dev none bind 0 0 +#/usr/bin ::BACKUP_ROOT::/usr/bin none bind 0 0 +#/usr/lib ::BACKUP_ROOT::/usr/lib none bind 0 0 +#/usr/share/perl ::BACKUP_ROOT::/usr/share/perl none bind 0 0 # END: rs-backup-suite