LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-11-2003, 06:06 PM   #1
G.P.P.
LQ Newbie
 
Registered: Jan 2003
Distribution: Slackware SUSE
Posts: 4

Rep: Reputation: 0
some script-question: date as filename


i would like to have a script for making a backup of my data on a webserver...
i thought of first savin the database to some *sql
and then zipping all files...
...this is no problem, but it would be usefull, if i could rename the files in the way that the date is patr of filename... but how to involve the date into filename?!

the so-far-script:
Code:
mysqldump -uusername -p database > ~/www/db.sql 
zip -R -9 -o ~/bak/latestbak ~/www/*

Last edited by G.P.P.; 01-11-2003 at 06:13 PM.
 
Old 01-11-2003, 06:29 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
you'd use backticks in the zip command

zip -R -9 -o ~/bak/backup-`date +%m-%d-%Y` ~/www/*

seems to make sense. you would have been able to jsut say date +%D but the standard date output contains /'s which is no use in a filename now is it? good golly no.
 
Old 01-11-2003, 06:30 PM   #3
J_Szucs
Senior Member
 
Registered: Nov 2001
Location: Budapest, Hungary
Distribution: SuSE 6.4-11.3, Dsl linux, FreeBSD 4.3-6.2, Mandrake 8.2, Redhat, UHU, Debian Etch
Posts: 1,126

Rep: Reputation: 58
DATESTRING=`date +"%Y%m%d"`

One must be very quick here.
Acid_kewpie posted a complete answer while I was pulling together some information to post my short one.

But I have a question: does zip store permissions in the archive? Not so long ago I throwed away zip and rather used tar + gzip for this purpose because zip did not seem to store the permission information with the archived files.

Last edited by J_Szucs; 01-11-2003 at 06:41 PM.
 
Old 01-11-2003, 06:41 PM   #4
G.P.P.
LQ Newbie
 
Registered: Jan 2003
Distribution: Slackware SUSE
Posts: 4

Original Poster
Rep: Reputation: 0
Thank you guys, also for your swiftness... This'll help me!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
script question lordofring Linux - Software 2 10-27-2005 01:15 PM
Script question yoderp Linux - General 8 07-06-2005 09:57 AM
Question on this script. Echo Kilo Programming 2 12-13-2004 05:20 AM
script question shanenin Linux - Software 2 04-04-2004 11:39 AM
Script Question blas Linux - General 5 02-14-2004 01:48 AM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration