Hi, thanks to everyone for your replies. The situation isn't really a standard backup as such, I am just doing a wget on a site that I want a local copy of so that I can tweak a file or 2, and upload back to the server - testing a new website. I want to always be working from the same folder as I have some shortcuts etc set up in Quanta and Konqueror. I'm only wanting to retain the last few copies of the working directory for disaster recovery purposes, hard drive space isn't going to be an issue and I'll manually delete some old folders as I go.

I make good use of $(date +"%Y-%m-%d) for tar file names in my backup scripts, and ultimately this proved to be the simple solution for me here, extending the folder name to include hour, minute and seconds like this:

MoveDirectory=$HOME/documents/$(date +"%Y-%m-%d-%H-%-M-%S")
StoreDirectory=$HOME/documents/newsite
mv $StoreDirectory $MoveDirectory
and then some other wget stuff follows...

Again, thanks for the help!
Roger



Ross Drummond wrote:
On Sat, 09 Feb 2008, Roger Searle wrote:
Hi, I have a script that does a wget on a website, which is working
well.  Before the wget command I am moving the folder that already exists:

mv $HOME/documents/newsite $HOME/documents/newsite-old

which is fine.  So long as the folder newsite-old doesn't already exist
because the script had previously been run and the folder exists.  If it
does, I'd get the following:

mv: cannot move `/home/roger/documents/newsite/' to a subdirectory of
itself, `/home/roger/documents/newsite-old/newsite'

What I would really like to do is be retaining each of the previous
copies of the newsite-old folder, and having the script append an
increasing number to the folder name each time it ran, ie newsite-old1
then newsite-old2 etc.

How could I modify the mv command so that it did this for me?

Hoping this makes sense,
Roger

I suggest that your script create a new directory each time it operates.

I would recommend that you incorporate the date in ISO 8601 format into your directory name. This means that file managers should by default list your directories in date order. You can add other info on for human readability purposes if you choose,

Here is how I would do it;

DirectoryName=/home/roger/documents/site/$(date +"%Y%m%d-%a%d%b")

Cheers Ross Drummond

Reply via email to