[NTLUG:Discuss] cop files with dynamic prefix
Wayne Walker
wwalker at bybent.com
Mon Dec 25 12:58:10 CST 2006
cd
mkdir bin
vi bin/archive_it
#!/bin/sh
SRC=myfolder
ARCHIVES=/home/wwalker/archives
DATE=`date +%Y%m%d`
if -d $ARCHIVES/${SRC}$DATE
echo "target already exists, PUNT"
fi
mkdir -p $ARCHIVES/${SRC}$DATE
rm $ARCHIVES/${SRC}
ln -s ${SRC}$DATE $ARCHIVES/${SRC}
cp -rp $SRC/. $ARCHIVES/${SRC}$DATE/.
OR use rsync with the --backup and --backupdir options
OR use subversion
According to what you are actually trying to accomplish, I'd probably
recommend rsync with incremental historical backups or subversion.
So, what areyou trying to accomplish?
Wayne
On Thu, Dec 14, 2006 at 07:04:34PM +0000, m m wrote:
> All:
>
> Can anyone help me with a script?
>
> 1. copy all files and sub directories in myfolder to backup directory
> 2. create a directory under backup and automatically add date as prefix
> 3. copy all files and sub directories in myfolder to newcreated directory
>
> for example
>
> the original folder/files
> somepath/myfolder/*
>
> after copy on the day of 12/14
> the folder will have
> backup/myfolder12142006/*
>
> and
>
> after copy on the day of 12/14
> the folder will have
> backup/myfolder12142006/*
> backup/myfolder12152006/*
> ...
>
> Does the shell can do it or need other 'language' tool (such as perl...) to
> achieve this task?
> Any code example would be appreciated!
>
> thanks.
>
> _________________________________________________________________
> MSN Shopping has everything on your holiday list. Get expert picks by style,
> age, and price. Try it!
> http://shopping.msn.com/content/shp/?ctId=8000,ptnrid=176,ptnrdata=200601&tcode=wlmtagline
>
>
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
--
Wayne Walker
www.unwiredbuyer.com - when you just can't be by the computer
wwalker at bybent.com Do you use Linux?!
http://www.bybent.com Get Counted! http://counter.li.org/
Perl - http://www.perl.org/ Perl User Groups - http://www.pm.org/
Jabber: wwalker at jabber.gnumber.com AIM: lwwalkerbybent
IRC: wwalker on freenode.net
More information about the Discuss
mailing list