[batch]Copy files/folders as backup
Jan 16
This is a simple batch code to do a simple backup of your files/folders. This batch will only copy your files/folder specified in the code to another location (external hardisk drive or other computer on the network)
First, set up your backup location, if you use external hardisk drive, make a backup directory. If the backup directory is on another computer, map the location on your pc using drive mapping (net use)
for this example code, I have set my B drive map a shared folder on another computer. Please note that the shared folder should be fully controlable – allow read/write / full permission
Copy and alter this code as you wish [code1]
REM -- ©SkeithLabs - 2010 color 2 @echo off echo automated backup REM -- start backup REM -- change the files/folders that will be backed up and the backup destination echo copying ... xcopy /e /y c:\mydb8 b:\data\mydb8 xcopy /e /y c:\mydbkppn b:\data\mydbkppn echo done msg %username% /time:30 "backup successfull or whatsoever" exit
Change the folder address on the highlighted code (left=source, right=destination). Then save the code as *.bat file (eg. mirror.bat).
Next is to copy and edit the following code to add those code above to the scheduled task [code2]
REM -- ©SkeithLabs - 2009 color 2 echo batch scheduled task echo will add mirror.bat to scheduled task echo will run every weekdays at 17:00 echo waiting for input pause REM -- start the at code echo adding task ... AT 17:00 /every:M,T,W,Th,F "C:\mirror.bat" echo done msg %username% /time:15 "task added, listed on scheduled task" exit
Save it as *.bat file (eg. mtask.bat).
The code above will make the mirror.bat (my code for backup is saved with this name) run every workdays at 17:00. Change the green code to your backup batch filename and location
Usage:
After saved, put both file on drive C, then run the second code (I saved it as mtask.bat) – It need only run once
Pertama, siapkan tujuan backup. Apakah menggunakan hardisk external atau jaringan. Siapkan folder tujuan backup di hardisk external atau lakukan mapping folder pada jaringan dengan drive mapping [net use]
Sebagai contoh, saya menggunakan drive B sebagai tujuan backup, dimana drive ini adalah mapping sebuah folder di jaringan. Folder yang di-map haruslah full permission / read/write
Copy dan ubah kode sesuai kebutuhan
lihat [code1] di atas
Warna merah adalah file atau folder yang akan di-backup, sedangkan biru adalah tujuan backup. Simpan kode sebagai *.bat (misal: mirror.bat)
Selanjutnya men-copy kode berikut untuk memasukkan batch di atas ke scheduled task
lihat [code2] di atas
Simpan sebagai *.bat (misal: mtask.bat)






