I am trying to create a tar backup script. I used the following article as my baseline:
https://help.ubuntu.com/community/BackupYourSystem/TAR
And this is what I ended up creating:
The problem is that as it runs, it tries to backup the tar backup file itself. I don't understand why, since the backup file lives inside /tmp. which is one of the directories I told it to exclude.Code:#!/bin/bash # init DATE=$(date +20%y%m%d) sudo tar -cvpzf /tmp/`hostname`_$DATE.tar.gz \ --exclude=/proc \ --exclude=/lost+found \ --exclude=/sys \ --exclude=/mnt \ --exclude=/media \ --exclude=/dev \ --exclude=/tmp \ --exclude=/home/jlacroix/Desktop \ --exclude=/home/jlacroix/Documents \ --exclude=/home/jlacroix/Music \ --exclude=/home/jlacroix/Pictures \ --exclude=/home/jlacroix/Projects \ --exclude=/home/jlacroix/Roms \ --exclude=/home/jlacroix/Videos \ --exclude="/home/jlacroix/.VirtualBox VMs" \ --exclude=/home/jlacroix/.SpiderOak \ / scp /tmp/`hostname`_$DATE.tar.gz jlacroix@Pluto:/share/Recovery/Snapshots sudo rm /tmp/`hostname`_$DATE.tar.gz
My second question, is if my exclusion of the ".Virtualbox VMs" folder is correct. It was the only folder that has a space in it, so I wrapped it in double quotes. Was that the right thing to do, or should I put all paths in double quotes to make it consistent?
Bookmarks