Results 1 to 3 of 3
Hi,
I'm a newb at shell scripting and need some help (obviously)
I have a script that makes a 7 day series of backups of some mysql databases.
The backups ...
- 10-14-2008 #1Just Joined!
- Join Date
- Jun 2008
- Location
- Toronto, ON
- Posts
- 4
copying newest directory through script
Hi,
I'm a newb at shell scripting and need some help (obviously)
I have a script that makes a 7 day series of backups of some mysql databases.
The backups go in a folder created by using `date +%a` (Mon, Tue, Wed, etc...).
These databases are stored on an external storage server and in the event of a failure i'd like to have a script to recover the newest backup folder to the local /var/lib/mysql folder.
Is there a way to tell which folder has the most recent creation date and copy it's contents?
*Edit* i should have also mentioned that this is on a server running Caldera Open Linux, kernel 2.4.19...fairly old and i've already had some problems getting some commands to run properly (like read -r...) This isn't even supported by SCO anymore and i can't update it since it belongs to another company.
Thanks
- 10-14-2008 #2Just Joined!
- Join Date
- Jun 2008
- Location
- Toronto, ON
- Posts
- 4
I solved this problem... Sorry for posting before doing alot of research, i was just on a deadline.
Here's how i did it
works like a charmCode:find /var/backup/db -type d -ctime 1 -maxdepth 2 -exec cp -rupv {} /var/lib/mysql/ \;
- 10-15-2008 #3Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
This probably does not affect your script, but "ctime" is actually the change time, not the creation time. Most unix file systems do not record the creation time of a file at all. Ext4 seems to be an exception in this regard.


Reply With Quote