I'm trying to build a backup script that creates a full tarball from my system each night. To do this I followed the tutorial here.
So to test it out I decided to create a manual backup:
tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz --one-file-system /
When I try to run this command I get the error:
tar: /run/: file is on a different filesystem; not dumped
This results in an exit code of 1. However, I want to run this command in a script and if the returncode is
0 I want to move the output file, otherwise delete it. If I understand correctly from the the tutorial linked above the
--one-file-system implies that
/run/ is ignored. But why do I get the error then?
For completness sake, the script (WIP) is shown below:
#!/bin/bash # Location to store backups STORAGE=/media/storage/backups/full # Current date DATE=$(date +"%d.%m.%YT%H.%M") TAR="$DATE.tar.gz" # Check if the file already exists. Should never be the case though. if [ ! -f /tmp/$TAR ]; then echo "Changing dir to /" cd / # Create tarball echo "Creating tarball" tar -cvpzf /tmp/$TAR --exclude=/tmp/$TAR --one-file-system / retcode=$? echo "Exit status: $retcode" if [ $retcode = 0 ] ; then echo "Moving file.." # Move the file mv /tmp/$TAR $STORAGE/$TAR echo "Done!" fi fi