homepage Welcome to WebmasterWorld Guest from 54.227.41.242
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

    
Backup Script no Making New Directory
matthewamzn

5+ Year Member



 
Msg#: 3008040 posted 7:23 pm on Jul 14, 2006 (gmt 0)

This is my backup shell script. I want it to create a backup directory and then put the backups in it. It doesn't seem to create the new directory.

----------------
#!/bin/sh
#backup website weekly

DATE=`date +%Y%m%d`

cd /var/www/vhosts/website.com/private/

mkdir $DATE-backups

cd

mysqldump --opt -uusername -ppassword dbname > /var/www/vhosts/website.com/private/$DATE-backups/backupsite-db-$DATE.sql

cd /var/www/vhosts/website.com/

tar -cvzf /var/www/vhosts/website.com/private/$DATE-backups/backupsite-backup-$DATE.tar httpdocs/

 

MattyMoose

10+ Year Member



 
Msg#: 3008040 posted 10:39 pm on Jul 14, 2006 (gmt 0)

when you run this, try running it with:

sh -x nameofscript.sh

See what is causing the errors.

matthewamzn

5+ Year Member



 
Msg#: 3008040 posted 2:56 pm on Jul 15, 2006 (gmt 0)

It looks like I have a lot of errors in my script. Why would this result in no file or directory found?

# sh -x backupscript.sh
++ date +%Y%m%d
+ DATE=20060715
+ cd $'/var/www/vhosts/website.com/private/\r'
: No such file or directory: /var/www/vhosts/website.com/private/
+ mkdir $'20060715\r-backups\r'
+ $'cd\r'
: command not foundne 7: cd

matthewamzn

5+ Year Member



 
Msg#: 3008040 posted 7:47 pm on Jul 15, 2006 (gmt 0)

I'm using EditPlus to create the script. Then saving it as a utf-8 file. Then uploading it in ascii mode.

NickCoons

10+ Year Member



 
Msg#: 3008040 posted 12:19 am on Jul 16, 2006 (gmt 0)

Why would this result in no file or directory found?

Because of this:

+ cd $'/var/www/vhosts/website.com/private/\r'
: No such file or directory:

It's telling you that the directory you're trying to change in to doesn't exist. Since the change directory command fails, the make directory command makes the directory wherever you're running the script from.

bcc1234

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3008040 posted 1:33 am on Jul 16, 2006 (gmt 0)

\r is the problem. You wan to save it in unix format with bare LF's.

Also, ${DATE}-backups is the correct way to make sure the shell knows at which character the name of the variable ends.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved