Tuesday, October 26, 2010

Backup files automatically!

When we use a computer, our files will store in the computer. Of course, all of us have known that we should backup our files frequently. Otherwise, when the hard disk is broken, our priceless files would be gone at the same time. If we use laptop, there will be another risk of loosing it or be stolen. In addition, I think that laptops are much easier to be broken, and when laptops are broken, they should be sent back to the service center to be fixed. There will be no chance for us to backup our files after laptops are broken. Unlike desktops, we can try to save our files after the desktop is crashed.

As I mention before, we should backup our files frequently. You may ask how frequently should we do? There is no standard answer for this question, honestly. It depends on how often we use computers. Take me as an example, I am postgraduate now, I have many important files every day, so I backup important files every day, and backup less important files once a month. The followings are some method I used to backup my files.

Dropbox
http://www.dropbox.com/

Dropbox is a web storage space which provides 2GB after we register an account. We can earn more spaces by inviting friends signing up in this website. The maximum space we can use free is 8GB. This website also provides a synchronized software. After we installing this software, there will be a new folder named "my dropbox" in the "my document" folder. When we put files in "my dropbox" folder, the files we put will be uploaded to web immediately. Last but not least,  we can install this software in many computers of ours even in iphone or android phone, and then all files we put in "my dropbox" folder can be accessed in these devices. Therefore, if one of our computer is broken, we can still use the synchronized files from other devices or from the website directly.

 There is an official video of introducing dropbox:




If you are interested in dropbox, and want to give it a try. Then sign up with this link:http://www.dropbox.com/referrals/NTMxOTk3MjI5, and you will get extra 250MB after you register an account.


Windows batch files and a 500GB external hard drive

Dropbox is a very ideal tool to backup our files, but unfortunately, there is only 2GB for us to use. That is not enough for me, so I bought a 500GB external hard drive to backup some files which is less important. My less important files are the files which I don't use very often such as the projects I have done, or the photos I took. I would backup these files in the external hard disk. However, these files are not in the same folder, so it would be very troublesome if I copy and paste these files manually, and plus, these files are really large. Therefore, I use 7zip and write a batch file with xcopy command and 7zip command to backup my files automatically.

Here is my batch files:
@echo off
@echo Backup Files
@echo.

@echo The following files will be backup:
@echo d:\software
@echo d:\chw
@echo d:\research tools
@echo.
@echo.


@pause

cls


@echo Backing up files please wait................
@echo.
@echo.



rem set date value
@For /f "tokens=1-3 delims=/ " %%a in ('date /t') do (set date=%%a-%%b-%%c)

rem @echo date is %date%


@echo Copying software files
xcopy d:\software d:\backup\"backup files"\backup-%date%\software /e /i /h /q
@echo.
@echo.


@echo Copying chw files
xcopy d:\chw d:\backup\"backup files"\backup-%date%\chw /e /i /h /q
@echo.
@echo.



@echo Copying research tools files
xcopy d:\"research tools" d:\backup\"backup files"\backup-%date%\"research tools" /e /i /h /q
@echo.
@echo.


@echo Creating log file in backup-%date%
cd d:\backup\"backup files"\backup-%date%\
@echo ==================================================== > "backup log".txt
@echo Files location: >> "backup log".txt
@echo ==================================================== >> "backup log".txt
@echo software        d:\software >> "backup log".txt
@echo chw            d:\chw >> "backup log".txt
@echo research tools        d:\ research tools >> "backup log".txt
@echo. >> "backup log".txt
@echo. >> "backup log".txt
@echo ==================================================== >> "backup log".txt
@echo Files informations: >> "backup log".txt
@echo ==================================================== >> "backup log".txt
dir d:\software /a >> "backup log".txt
@echo ------------- >> "backup log".txt
dir d:\chw /a >> "backup log".txt
@echo ------------- >> "backup log".txt
dir d:\"research tools" /a >> "backup log".txt
@echo. >> "backup log".txt
@echo. >> "backup log".txt
@echo ==================================================== >> "backup log".txt
@echo These files were backup on %date% >> "backup log".txt
@echo ==================================================== >> "backup log".txt
@echo Log file has been created

@echo.
@echo.

rem compress files to 7-zip
cd d:\backup\
7za a -scsUTF-8 -mx=9 d:\backup\"backup files"\backup-%date%.7z  d:\backup\"backup files"\backup-%date%\

@echo.
@echo.


@echo done!
@echo Files has been backuped in d:\backup\backup files\backup-%date%.7z
@echo.
@echo.


@pause

rem delete the folders
del /S /Q d:\backup\"backup files"\backup-%date%\
rd /S /Q d:\backup\"backup files"\backup-%date%\

I have to say it is not easy for me to write this file. I spent two hours finishing this files. If you want to try this method, you should download 7-Zip Command Line Version, and refer to the xcopy read me file. Other commands I used are echo, del and rd in the batch file. You can learn how to write a batch file in here, or just google it. I am sorry that I don't know how to write because I am not familiar with batch files, and I finished this batch files with google. Wish you enjoy it!

PS.
This is my first time to write a how to article. I hope all of you can know what I was writing.

No comments:

Post a Comment