Jump to content

Recommended Posts

Posted (edited)

i have a cron script that tars up some stuff to a tar file that appends the days date to the filename, and then uploads it offsite

 

tar -cf backup_`date +%Y-%m-%d`.tar /home
perl ftpput.pl --user=username --pass=password7 --dir=backup --binary --server=ftp.backup.com backup_`date +%Y-%m-%d`.tar

 

Works great, uploads fine

 

However on another location, Im trying to grab that file, and extract it, but wget doesnt seem to like the date variable and comes back with a 404

 


wget http://wwww.backup.com/backup_`date+%Y-%m-%d`.tar
02:28:09 ERROR 404: Not Found.

 

Is there any way of using wget with a date variable like that?

 

(wasnt sure to post this in linux or scripting forum so plz move if needed)

Edited by RabbieBurns
Posted

I hit this kind of hurdle too and found it easier (read: saner) to use sftp for security and because you can script in a job.

 

I'll have a think on the wget one this morning.

Posted

Ah, having looked at it, your wget is incorrectly laid out for the date. (needs a space between date and +).

 

wget http://wwww.backup.com/backup_`date +%Y-%m-%d`.tar

 

Works.

 

Also worth bearing in mind, if you're running/grabbing back ups over timezones/midnight be careful of the change of date! Kept me amused for a few hours working that one out.

  • Thanks 1
Posted

wget -c

 

Don't forget the -c (valuable in regards to lost packets and download stopping)

 

Could CTRL+C a long download with the -c switch, retype the exact command, and it will continue from where it left off!

  • Thanks 1
Posted
Variable expansion has nothing to do with wget. It is done by the shell before the parameter (in this case a url) is passed to the program being called (in this case wget). I suggest you replace the wget command with an echo, then you can inspect the variable expansion and check that it is correct. If there's still something strange going on, add a 'set +x' to the beginning of your script and observe the output when you run the script manually.
  • Thanks 1
Posted

Thanks kmount for pointing out the missing space, and geoff for clarifying things, but it has taken me till now to realise i put wwww instead of www and that was another reason why it wasnt working :doh:

 

All working now :) No timezones to worry about, but thanks for the tip.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...