# Script to back up files



## narutrix (Feb 7, 2010)

Hi Guys,

need your assistance in making a script to automate the back up process that I''ve been doing
that's too manual  and I don't know how to begin too.

Basically, what I need to do is to back up the call recordings and it's database to a USB External drive. To explain better my problem, let me define first the terms I'm going to use:

server 1 - voice recording server
server 2 - database server

Steps I do:

1) USB External HDD is connected in server 1. It can only contain 3 days of back up, so I have to delete the oldest recording folder first (duration to delete files is 10 mins). I also create a new folder (format: backup10-Feb-2013)

2) I go to server 2 to run the following command:

:cd\program files\cisco\wfo_qm\bin\bars.exe
(duration of running the program running is 2 mins)

back up files are stored in C:\program files\sqm\backup

I now log off from Server 2.

3) once there is enough space already in the USB External HDD that is connected in server 1, i now copy the backed up database from \\server 2\c$\program files\sqm\backup to the USB External HDD (location is the new folder that I created in step 1) that is connected in server 1. 

4) After additional free space is available in the USB External HDD, I copy now the recordings in Server 1 (drive d) to the the USB External HDD (location is the new folder that I created in step 1) that is also connected in server 1. 

I have to do the steps above every night at 7:30pm .

Is there a way to automate the processes ?


----------



## foxidrive (Oct 20, 2012)

Basically, what I need to do is to back up the call recordings and it's database to a USB External drive. To explain better my problem, let me define first the terms I'm going to use:

server 1 - voice recording server
server 2 - database server

Steps I do:

1) USB External HDD is connected in server 1. It can only contain 3 days of back up, so I have to delete the oldest recording folder first (duration to delete files is 10 mins). I also create a new folder (format: backup10-Feb-2013)

Problem 1: detect the USB drive letter.
You can solve this by putting a known text file in the root of the USB drive so it can be detected and the drive letter extracted.

Please supply the folder path that the backups are using.

Consider changing the backup foldernames to 'backup2013-02-10" which is easy to derive and sorts naturally in the folder.

Deletion of the oldest backup can be done here but it can also be done after the new set of data is created. In case something hangs in creating the new set of data then you will still have the extra backup.

2) I go to server 2 to run the following command:

:cd\program files\cisco\wfo_qm\bin\bars.exe
(duration of running the program running is 2 mins)

back up files are stored in C:\program files\sqm\backup

I now log off from Server 2.

Use PSexec to launch this command with syntax like this to wait for the command to complete.
start "" /w ":cd\program files\cisco\wfo_qm\bin\bars.exe" 


3) once there is enough space already in the USB External HDD that is connected in server 1, i now copy the backed up database from \\server 2\c$\program files\sqm\backup to the USB External HDD (location is the new folder that I created in step 1) that is connected in server 1.

Robocopy in vista and later is useful to mirror a folder tree, but you will have to supply credentials to access the server2 if it requires a username and password. Ditto for step 2)
Thus your username and password will be in the batch file in clear text.

4) After additional free space is available in the USB External HDD, I copy now the recordings in Server 1 (drive d) to the the USB External HDD (location is the new folder that I created in step 1) that is also connected in server 1.

Are these the same set of files that are created in step 3) ?

I have to do the steps above every night at 7:30pm .
Is there a way to automate the processes ?

Once you have a tested batch file you can schedule it to run at 7:30 nightly.


----------

