Tuesday 25 February 2014

Back up with a Batch file

Back up with a batch file:
This batch file has a menu and an Unattended option.



I have created this back up with a menu i created this batch file for my own personal PC, but you may copy, paste and modify it to suit your own needs.

Points to remember when modifying
Use the correct user and drive letters and paths.
Email path directories will vary  from user to user and is also dependent on the email program used.
(For instance my email is  program is microsoft outlook and the data file -PST- is located in Outlook folder in root directory of my C: drive.- not standard but that is where mine is.)

copy from here


@echo off
@color F9
title DurbanGeek BACK IT UP 2.0



:MAINMENU
mode con: cols=50 lines=21
CLS
echo.
echo.
echo.    DURBANGEEK ~  IT Solutions  0711035273
echo.    Durbangeek Custom BACK IT UP Utility
echo.     **********Kenny Godfrey***********
echo.
echo.
echo.              A. Back Up Documents
echo.              B. Back Up Pictures
echo.              C. Back Up Email
echo.              D. Back Up Desktop
echo.              E. Back Up *****
echo.              F. Back Up *****
echo.              G. Back Up Google Drive
echo.              H. Back Up Everything (Unattended)
echo.              Q. Quit
:CHOOSEACTION
echo.
set /p userinp=    ^   Make your selection:
set userinp=%userinp:~0,1%
if /i "%userinp%"=="A" goto Documents
if /i "%userinp%"=="B" goto Pictures
if /i "%userinp%"=="C" goto Email
if /i "%userinp%"=="D" goto Desktop
if /i "%userinp%"=="E" goto *****
if /i "%userinp%"=="F" goto *****
if /i "%userinp%"=="G" goto Google Drive
if /i "%userinp%"=="H" goto Everything
if /i "%userinp%"=="Q" goto Quit
echo.Try Again...
GOTO CHOOSEACTION

:Documents
mode con: cols=128 lines=42
title BACK IT UP  2.0
echo ********* Please make sure  all Documents are saved and closed. *********
echo ********* Press a key to continue ********
pause
echo.    Backing up Documents !!!!!!!
xcopy  C:\Users\User\Documents\*.* H:\DGBackup\Documents\ /D/S/H/V/C/F/K/Y
echo.
echo.Documents back up completed :)
echo.
echo ************Press any key to return to the main menu*************
PAUSE 1>nul
GOTO MAINMENU
)
echo ************Press any key to return to the main menu*************

:Pictures
mode con: cols=128 lines=42
title DurbanGeek BACK IT UP  2.0
echo ********* Please make sure  all Pictures are closed. *********
echo ********* Press a key to continue *********
pause
echo.    Backing up Pictures !!!!!!!
xcopy  C:\Users\User\Pictures\*.* H:\DGbackup\Pictures\ /D/S/H/V/C/F/K/Y
echo.
echo. Pictures back up completed :)
echo Press any key to return to the main menu
PAUSE 1>nul
GOTO MAINMENU
)
echo ************Press any key to return to the main menu*************

:Email
mode con: cols=128 lines=42
title DurbanGeek BACK IT UP  2.0
echo ********* Please make sure  Microsoft Outlook is closed *********
echo ********* Press a key to continue *********
pause
echo.    Backing up Email !!!!!!!
xcopy C:\Outlook\*.* H:\DGbackup\Outlook\  /D/S/H/V/C/F/K/Y/Z
echo.
echo.  Email back up completed :)
echo.
echo Press any key to return to the main menu
PAUSE 1>nul
GOTO MAINMENU
)
echo ************Press any key to return to the main menu*************

:Desktop
mode con: cols=128 lines=42
title DurbanGeek BACK IT UP  2.0
echo.    Backing up Desktop !!!!!!!
xcopy  C:\Users\User\Desktop*.* H:\DGbackup\Desktop /D/S/H/V/C/F/K/Y
echo.
echo.  Desktop back up completed :)
echo.
echo.Press any key to return to the main menu
pause > nul
GOTO MAINMENU
)
echo ************Press any key to return to the main menu*************

:Google Drive
mode con: cols=128 lines=42
title DurbanGeek BACK IT UP  2.0
echo.    Backing up Google Drive !!!!!!!
xcopy  "C:\Users\User\Google Drive\*".* "H:\DGbackup\Google Drive\" /D/S/H/V/C/F/K/Y
echo.
echo.  Google Drive back up completed :)
echo.
echo.Press any key to return to the main menu
pause > nul
GOTO MAINMENU
)
echo ************Press any key to return to the main menu*************

:Everything
mode con: cols=128 lines=42
title DurbanGeek BACK IT UP  2.0

echo.     * * * * Backing up Documents !!!!!!! * * * *
xcopy  C:\Users\User\Documents\*.* H:\DGBackup\Documents\ /D/S/H/V/C/F/K/Y
echo.
echo.  Documents back up completed :)
echo.
echo.     * * * * Backing up Pictures !!!!!!! * * * *
xcopy  C:\Users\User\Pictures\*.* H:\DGbackup\Pictures\ /D/S/H/V/C/F/K/Y
echo.
echo.  Pictures back up completed :)
echo.
echo.
echo.    * * * * Backing up Email !!!!!!! * * * *
xcopy C:\Outlook\*.* H:\DGbackup\Outlook\  /D/S/H/V/C/F/K/Y/Z
echo.
echo.  Email back up completed :)
echo.
echo.
echo.     * * * * Backing up Desktop !!!!!!! * * * *
xcopy  C:\Users\User\Desktop*.* H:\DGbackup\Desktop\ /D/S/H/V/C/F/K/Y
echo.
echo.  Desktop back up completed :)
echo.
echo.
echo.     * * * * Backing up Google Drive !!!!!!! * * * *
xcopy  "C:\Users\User\Google Drive\"*.* "H:\DGbackup\Google Drive\" /D/S/H/V/C/F/K/Y
echo.
echo.  Google Drive back up completed :)
echo.
echo.
echo.  Unattended BACK IT UP up was completed :)
echo.Press any key to return to the main menu
pause > nul
GOTO MAINMENU
)
:Quit


 ↑ copy to here ↑



Instructions :
Open a new text docunent.
Paste  text into document
Select file then save as
Change the name to BackUp.bat (remove the .txt)and save to the desktop
The icon should look something like this             >>>>>

Now assuming that you have edited the commands correctly you will now be able to back up a folder or do a complete unattended backup.