I have a directory with thousands of files. They have a specific creation date. Now I want to archive these files on specific times to a specific directory.
Example:
Files created on:
May 15 testmay.txt
Jun 10 testjun.txt
Jul 01 testjul.txt
They should come in those directory's
/2013-05/testmay.txt
/2013-06/testjun.txt
/2013-06/testjul.txt
I already have this to rsync the files from a remote server to a temp month directory.
#!/bin/sh
GAMESERVER=game01
IP=172.1.1.1
JAAR=`date --date='' +%Y`
MAAND=`date --date='' +%m`
DAG=`date --date='' +%d`
LOGDIR=/opt/archief/$GAMESERVER
if [ ! -e $LOGDIR/$JAAR-$MAAND ]; then
mkdir $LOGDIR/$JAAR-$MAAND/tmp
chmod -R 770 $LOGDIR/$JAAR-$MAAND/tmp
fi
rsync -prlt --remove-source-files -e ssh root@$IP:/opt/logs/sessions/ $LOGDIR/$JAAR-$MAAND/tmp
chmod -R 770 $LOGDIR/ -R
How can I complete this script?