This is going to explain some ideas for a really simple way to make your own backup routine.
This isn’t very fancy and in some ways it’s not the best backup solution. Let me explain what to use this for. This kind of tool can be used to “save you from yourself.” For example…. “oops I wrote over my … file”.
One solution that I’ve come up with under windows or linux is a simple batch or command script. Most computer users today have sweaty palms when they see that black screen with a little white command prompt, but it does hold great simplicity and flexibility.
Under windows. Let’s say I want to copy a file from My Documents to a folder called backups. Open up a command shell in the My Documents folder (this may be the hardest part. You may need to navigate to the My Documents folder through the command line which can be a little tricky. That might be worth another article.)
If your prompt does show that your in the right folder you can type dir to get a listing of the folder. It may be a long list, but let’s say your file is called myfile and it’s a word document, (so it’s probably really called myfile.doc). Then typing the following
copy myfile.doc backupmyfile.doc
That should put a copy of the said file in your backup directory. now this assumes you had already created that backup directory and it was in the My Documents folder. So how can we automate this? Open up notepad. No, not word, notepad. (Start, Run… notepad.) type the commands that you needed to get to the My Documents folder, then type the copy command that you used. Go to file and then save, choose ALL file types and save as mybatchfile.bat (It’s important to have ALL file types set or it will add .txt to the end which will prevent it from being run.)
Now you might save it My Documents if you like (then you won’t have to include the navigation to the My Documents folder).
Now browse to My Documents and find mybatchfile – doubleclick it. It may flash by quickly, but it may be stopped to ask a question. That’s because the copy command is usually reluctant to overwrite a file, so if your myfile.doc exists in the backup folder we need to tell it to overwrite. Open the file back up in notepad and where you have
copy myfile.doc backupmyfile.doc
add this to the end of the line /Y so that it looks like this.
copy myfile.doc backupmyfile.doc /Y
This should tell the copy command to answer Yes to the overwrite question. Save and close again and test the batch file.
You can use this with multiple files as well. The big thing to notice is this…. this will not protect your data against a hard drive failure since the backup is stored on the same drive as the original data. It might give you a safety net for when “word eats your homework..”
Under linux the commands are a bit different. Open any text editor. we’ll assume that your file is in /home/yourusername/documents. Let’s make sure the script is started out right.
Put the following in your new text document
cp myfile.doc ./backup/ -f
That’s it. I’ve condensed the steps here a bit since I’ve explained things a bit more for the Windows folks. For starters under linux scripts need to be told how to be interpreted. There are perl scripts/php etc. This is going to be using the bash shell and that’s what the first line sets. The second line navigates to the directory where your file is. Third line is linux’s copy command (cp) and the -f at the end “forces” the copy to take place even if the file already exists there. Of course, here again we’re assuming you’ve already created a backup folder under /home/yourusername/documents
Save and close from the file, let’s name it myscript.sh under linux the filename doesn’t have any bearing on whether or not it can be executed, I just like tagging shell scripts with the .sh ending to visually sort them. We do need to make sure we can run it though. In konqueror (if you use kde) you can navigate to where you saved the script, right click and go to properties and set it executable. Other gui’s should give you similar possibilities. Of course, you can drop to the command line and navigate to the file’s directory, then type
chmod +x myscript.sh
and press enter. then to run it you can either doubleclick it in the file browser, or type ./myscript.sh from the command line if you’re in the directory that you’ve saved it.
Related PostsRelated Posts
- Planning for disaster recovery This covers all operating systems really. What would happen if your hard drive crashed right now? What data would you lose? What about if the server room flooded? What if your mission critical system went down. What data would you lose and how long would it take to be back......
- A closer look at x11vnc I've got to say, one of the things I really like about linux are the myriad of options for remotely administering a system. SSH is the one I use the most, but for the graphical you have x (especially on the LAN), nxserver (which is a compressed and optionally encrypted......
- More Fake security sites More sites that claim to be windows security center or the like are popping up... a list: securitycaution(dot)com dnserror404(dot)com todaywarnings(dot)com updatesystempage(dot)com yoursecuritysystem(dot)com From sunbeltblog. There's a post at sysinternals about the bogus security software that's out there. Spyaxe, among others, pose as "antispyware software" and bring along more problems than......
- Filing Tips for the Last Minute Filer [The following guest blog post was provided by Manuel Davis, a tax accountant at Back Taxes Help, who has helped thousdands of taxpayers file IRS back taxes and setup IRS Payment Plans.] In the remaining few days before the 2009 income tax deadline, millions of taxpayers will be rushing to......
- Add more destinations to the "Send To" right click menu There are tons of little tweaks to XP out there that make the GUI more useful. One of the things I've found is that the default elements of the contextual menus in XP do not always have everything you want in them. Thankfully, much of these things are customizable. I......
- Home Office Ideas Home working has reached a level where it has once again become a major part of the economy. It is especially big in Europe. For example, approximately 4 million residents in the UK work from home necessitating the need to optimise their office spaces in order to improve efficiency, while......
- Using the command line in linux – part 2
- Another workaround for WMF exploit
- Recovering a Split BiggieFile from a MondoRescue Backup
- Backing up and restoring MySQL databases
- Rsync for easy (and quick) backups