views:

11

answers:

1

Hello,

CentOS 5.3

I have a script file that works for backing up a repository and I am using rsync to copy the contents to the source directory.

I have a crontab job that runs every night at 12am that calls my script file. repos_backup.sh

rsync -razv [email protected]:repos /home/backup_sys_user/repos_backup

However, this puts all the repositories in repos_backup directory. However, I am looking for a way to create a new directory based on the date the backup was done. So I should have a directory structure like this:

/repos_backup/10.10.2010
             /11.10.2010
             /12.10.2010

I haven't done much scripting before, is there anyway to do this.

Many thanks for any advice,

Steve

+1  A: 

You can use:

date +%m.%d.%Y

To get the current date (e.g. 10.10.2010)

To include it within a command, you can do:

mkdir ~/myuser/`date +%m.%d.%Y`/backup

Note that the those are tick marks.

Eric Wendelin