Search code examples
debianbackuprsyncsymlinknfs

Why points rsnapshot backup to live-system?


I have setup rsnapshot with a cron job and stored 7 daily backups of my online server to a backup storage. Everything seemed to went fine since I could access everything in my backups I mounted via NFS.

One day I actually needed to restore a lost important file from my backup. Unfortunately each daily backup just showed me the content of the live system. Every change I made on the live server was instantly done in any backup as well.

It seemed like there was no real backup, but only alternative link structures pointing to the same live-system. This for sure wasn't what I needed.


Solution

  • Be aware of symbolic links (aka symlinks)! They get rerouted to the live system - even if you use them in a backup path!

    In my case I wanted to restore a file from a web project. Since my server administration tool ISPconfig generates a hierachical structure and shorter symlinks I am used to take advantage of those symlinks without even thinking about it any more.

    The actual server path is:

    /var/www/clients/clients1/web1/web/
    

    but normally I use the more convenient symlink:

    /var/www/domain.ext/web/
    

    If you use the symlink in your mounted backup you will end up in the live system. Since you are accessing it from the system where those links refer to the live system:

    /mnt/backup/daily0/localhost/var/www/domain.ext/web/
    

    leads you to to:

    /var/www/domain.ext/web/
    

    but you are actually seeing the path to the backup you typed in above.

    If you want to reach the actual backup content you need to use the real path without symlinks:

    /mnt/backup/daily0/localhost/var/www/clients/client1/web1/web/
    

    You can check for symlinks by using the ls command with a more elaborate output like "ls -l".