Technology news and Jobs arrow Seeking Nerdvana arrow The Road to Ubuntu - Backup Salvation
The Road to Ubuntu - Backup Salvation E-mail
by Adam Turner   
Monday, 05 November 2007
I want to keep multiple copies of my backup folder, say every 10 minutes for 48 hours, so I can dip back into previous versions in case I want to recover something I deleted. I know this sounds like overkill but it's a luxury I had when I worked in a newspaper office, and now that I work for myself I don't want to give it up.

I discovered I could keep multiple versions by renaming the folders like this;

mv ${des}/3 ${des}/4
mv ${des}/2 ${des}/3

mv ${des}/1 ${des}/2


Folder number 1 becomes 2, 2 becomes 3 and so on. While this worked, it's not very practical if you want to keep hundreds of folders. I did a lot of basic programming on a Commodore 64 as a kid, so I've got an idea of how programs work even if I don't know all of the commands and syntax to use with Ubuntu. I knew I needed a loop and, after a few Google searches, I came up with this;

# Number of copies to keep
count=5


# delete oldest folder

rm -rf ${des}/${count}


# stop loop when count is not greater than 1

while [ $count -gt 1 ]   


# loop to rename folders

do

old=`expr $count - 1`

mv ${des}/${old} ${des}/${count}

count=`expr $count - 1`

done


It might not look like much, but it did the trick and I was pretty pleased with myself. The problem is I wanted timestamped folders, but I couldn't figure out how to renumber the folders while retaining the timestamp in the name. I took another approach, looking for a way to delete folders according to their age, and found this on howtogeek which deletes folders more than 5 days old;

find /path/to/files* -mtime +5 -exec rm {} \;

Adapting my script, I came up with;

# Source
sou="/windows/data/Documents and Settings/Adam/My Documents/Adam/Work/AAA In Progress"


# Destination
des="/windows/Public/ubuntubackup"


# Number of days to keep files

days=5


now=$(date +%y-%m-%d_%H:%M)

mkdir ${des}/${now}

cp "${sou}"/* ${des}/${now}

find ${des}/* -mtime +${days} -exec rm {} \;


It seemed to work perfectly, but then things went screwy and the folders a being renamed with temp names like 0N47VU~S on the network drive rather than timestamps. Any suggestions would be greatly appreciated, but meanwhile at least my numbered folder system works.

With my local backup needs taken care of, it was time to turn my attention to FTP. CONTINUED



 
< Next story in category   Previous story in the category >
iTWire user statistics Visitors last 30 days
694,279
Subscribers 15,210
#1 independent technology news advertise here
  •   *  
  • Search
  • AdvSeach
  • Login
  • Events
  • FreeStuff

- Advertisement -

Featured Whitepapers

The Digital Lounge Room

Seeking Nerdvana - Attaining oneness with tech Subscribe to the RSS
Seeking Nerdvana follows Adam Turner's quest to attain oneness with technology. Embedded in the digital lounge room, Adam offers a view from the couch of the front line where PC converges with AV.
Follow iTWire on Twitter

About iTWire

iTWire is all about technology news, information, jobs and community for the IT and telecommunications industry professional. Subscribe to our free ICT daily newsletter