How To Automatically Backup Files

How To Automatically Backup Your Files

Backup Your Files Automatically

My main task on our company is to create web-based programs. On our company, once a project is finished, you are committed to maintain and monitor everything about the system that you have created, and that includes ensuring a backup to your templates and most especially to your database.

The thing is, on our company, supervision is not that abundant as we are trimmed to accomplish everything with none or little assistance. You are on your own, the key is to become resourceful as you can.

So backing up my files and databases are all done manually, take this...for years. That may be a little embarrassing for the pros, but no ones teaching us, and as far as I know it, that's the way it can be done.

Not until one day where I got all tired up for backing up manually. So I searched for ways to do it automatically.

Here's what I want - I want a folder created automatically on the location that I want and I want that folder to be named base on the date like mm/dd/yyyy. That is the folder where I will house all of the files from our server.

Here's what I know how to do so far. I know how to copy files using DOS command and I know that a DOS command can be put on a batch file and I also know that a batch file can be triggered using the "Task Scheduler" which is built-in on windows.

My only problem is on how can I create a folder named based on the current date.

But googling to find information on some helpful websites can really give you what you wanted. I picked one thing from a site and one from more others and when I combined them, I just got what I want.

Enough introduction, here's how you can create a folder named on the current day on DOS.

md c:\%date:~4,2%%date:~7,2%%date:~10,4%-%time:~0,2%%time:~3,2%

That simple code will create a folder named on the current date based on the mm/dd/yyyy format.

You can then copy your files with this usual DOS copy command.

mcopy /s/e /i \\Server\Source_Folder E:\Destination_folder\%date:~4,2%%date:~7,2%%date:~10,4%

I then saved it as backup.bat, then make it run when most people are not using the system using the 'Task Scheduler' of windows OS.

If you want, you can add the command...

pause

..on the last part on the batch file to see the confirmation that all files has been copied.

Well, that's all on it.

Happy coding!

0 Comments :

Post a Comment