LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   help with backup script (https://www.linuxquestions.org/questions/linux-networking-3/help-with-backup-script-199053/)

dennis_89 06-29-2004 08:06 AM

help with backup script
 
I am wondering if anyone could help with a backup script. I am kind of new to this scripting stuff, so any help would be great. Here is the code I am using:

Code:

#/bin/bash
#linux/windows backup script for network shares
#to external hard drive
#written by: dennis williams
#june 29, 2004
#
#-------These are the environment variables----------------
#
$USERNAME1=username
$PASSWORD1=password
$TARGET_MACHINE=target_machine_name
#
#-------Backup_share can also be set where "mount -t smbfs" is below
#-------this is good if there are spaces in the share name
#
#$BACKUP_SHARE=name_of_the_share_on_the_windows_computer
#
#------------End Variables---------------------------------
#
#------------where all of the work is done-----------------
#
#if mount | grep -q /mnt/backup; then
#    echo "backup is already in progress" >&2
#    exit 1
#fi
#mount -t smbfs "//$TARGET_MACHINE/$BACKUP_SHARE" /mnt/backup -o "password=$PASSWORD1,username=$USERNAME1"
#(cd /mnt/backup; tar -cvp .) | bzip2 >"$DRIVE/$TARGET_MACHINE.tar.bz2"
#umount /mnt/backup
#
#-----------checks to see if the backup has already started------------
#
if mount |grep -q /mnt/backup; then
  echo "backup is already in progress" >&2
  exit 1
fi
#
#---------------------------ends the check-----------------------------
#
mount -t smbfs "//$TARGET_MACHINE/$BACKUP_SHARE" /mnt/backup -o "password=$PASSWORD1, username=$USERNAME1"
(cd /mnt/backup; tar -cvp .) | bzip2 >"$DRIVE/$TARGET_MACHINE.tar.bz2"
umount /mnt/backup
#
#-------------------------end of script--------------------------------
#----you will be left with a tar file with the name of the computer----
#

and this is the error I am getting:

Code:

-----ends the check---
#
mount -t smbfs .... etc
*
Could not resolve mount point /mnt/backup
(cd /mnt/backup; tar -cvp .)bzip2 >$DRIVE/$TARGET_MACHINE.tar.bz2
laptop.txt: line 40: cd: .mnt/backup: No such file or directory
./
./cron.txt
./backup.txt
./master.txt
./drive
./christa.txt
./laptop.txt
umount /mnt/backup
umount: /mnt/backup: not found
#

That is the code and the error, is anyone able to help out??

Thanks,

Dennis

init 06-29-2004 09:43 AM

A guess for ya,

Put /mnt/backup in your fstab and make sure the directory is created under /mnt

I assuming this /mnt/backup is on a differnt machine a samba share.

Code:

$USERNAME1=username
$PASSWORD1=password
$TARGET_MACHINE=target_machine_name

also I dont think you want a $ in front of you variables at this point in time in the script

Here you are just setting the variables later you use them in which you would use the $USERNAME1 and such....

like i siad just a guess, feel free to slap me if i am wrong :D

dennis_89 06-29-2004 09:47 AM

yup, definitely have to lose the $.

Thanks,

Dennis


All times are GMT -5. The time now is 10:43 PM.