Announcement

Collapse
No announcement yet.

Automated Backup Script (OpenSource)

Collapse
X
 
  • Filter
  • Time
Clear All
new posts

    Automated Backup Script (OpenSource)

    Hi Guys,

    We've put together an unofficial script that should assist many users in getting their backup processes more or less automated. this script s been written in a way that users can take the parts that they need (sections marked off in the code), and incorporate them into their backup processes, or they can use the whole script as it is.

    Please note that this script is not to replace your usual backup process.

    When copying the script, please save it in a text file named RangerMSPAutoBackup.cmd, located on a different drive than the RangerMSP system (in any folder you wish). This is so that the backups don't get created on the drive that hosts RangerMSP, and the separation between the system & your backups is preserved.

    Once you have the script saved, please download zip.exe (obtainable from google), and save the file in the same folder as the script.

    The last step is to run the backup script, while adding the path to your RangerMSP folder as a command line parameter (No Backslash at the end of the path).

    I.E. D:\>RangerMSPAutoBackup.cmd C:\RangerMSP

    Here's the script:

    @echo off
    REM ================================================== =====================
    REM
    REM
    REM Disclaimer:
    REM This script has been created as a functional sample, in order to help to automate
    REM your backup process. The script has been divided into sections so that you can easily
    REM re-engineer the script to better automate your current backup method. This script
    REM is not meant to replace your current backup method in any way, RangerMSP Business
    REM Solutions Ltd or any of its employees do not take any responsibility for the data
    REM stored in any backup and we highly suggest to keep all backup archives as separate
    REM as possible from the main RangerMSP data, as well as implementing additional
    REM safety & backup measures so that your data will not be in any risk of being lost.
    REM
    REM What this script does:
    REM The script performs the following steps:
    REM 1) Gather RangerMSP folder from Command-Line Parameter
    REM 2) Create Database "Stop" file, for a safe backup (Disconnects all users from the system)
    REM 3) Pause for 5 minutes. (Should be enough for all connections to be termiated)
    REM 4) Compress RangerMSP data into a Zip archive (Archive is created in the same folder as the script
    REM is run from)
    REM 5) Delete Database Stop file
    REM
    REM Important Note: This backup script does not backup any of your Documents files, including ones
    REM “attached” to RangerMSP;
    REM please remember to backup your documents files in a separate archive.
    REM
    REM Once the Database stop file has been deleted, the database is reactivated, and your users will
    REM be able to connect to the system again.
    REM
    REM
    REM Parameters:
    REM %1: Local path to RangerMSP CRM. When running the Backup script, the script needs you to input
    REM the RangerMSP Folder Path in the command line right after the script name. Path must not end with
    REM a BackSlash \
    REM
    REM
    REM General Usage Example:
    REM :\>RangerMSPAutoBackup.cmd C:\RangerMSP
    REM
    REM
    REM Dependencies:
    REM This script needs to be saved in a separate drive from the RangerMSP System files.
    REM Please copy Zip.exe in the same folder with this script.
    REM Zip.exe (Free Compression Tool) is easily obtainable from many places on the internet. We
    REM suggest finding it in Google.
    REM
    REM ================================================== ================

    if ###%1###==###### goto NoParam
    goto ParamsFound

    :NoParam
    echo.
    echo Missing path. Enter the local path to the RangerMSP CRM root directory.
    echo Example: RangerMSPAutoBackup.cmd C:\RangerMSP
    echo ================================================== ================
    Echo Zip.exe (Free Compression Tool) is easily obtainable from many places
    echo on the internet. We suggest finding it in Google.
    goto End

    :ParamsFound
    REM = Close Datamase Connections======================================
    if exist "%1\DbSys\RangerMSPStop.ini" del "%1\DbSys\RangerMSPStop.ini"
    echo [TERMINATE] > "%1\DbSys\RangerMSPStop.ini"
    echo TimeBeforeAutoTerminate=1 >> "%1\DbSys\RangerMSPStop.ini"
    echo Stopping database connections...
    echo Waiting 5 Minutes...
    REM=============================================== ====================

    REM = This section pauses the script for 5 minutes.===================
    echo Time remaining until Backup - 5:00
    Ping -n 30 127.0.0.1 >NUL
    echo Time remaining until Backup - 4:30
    Ping -n 30 127.0.0.1 >NUL
    echo Time remaining until Backup - 4:00
    Ping -n 30 127.0.0.1 >NUL
    echo Time remaining until Backup - 3:30
    Ping -n 30 127.0.0.1 >NUL
    echo Time remaining until Backup - 3:00
    Ping -n 30 127.0.0.1 >NUL
    echo Time remaining until Backup - 2:30
    Ping -n 30 127.0.0.1 >NUL
    echo Time remaining until Backup - 2:00
    Ping -n 30 127.0.0.1 >NUL
    echo Time remaining until Backup - 1:30
    Ping -n 30 127.0.0.1 >NUL
    echo Time remaining until Backup - 1:00
    Ping -n 30 127.0.0.1 >NUL
    echo Time remaining until Backup - 0:30
    Ping -n 30 127.0.0.1 >NUL
    echo Backing up your data momentarily.
    Ping -n 5 127.0.0.1 >NUL
    REM=============================================== ====================

    REM = Backup Command=========================================== =======
    For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
    For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
    zip -u RangerMSP_Backup_%mydate%_%mytime% %1\db\*.* %1\dbsys\*.* %1\filters\*.* -x RangerMSPstop
    REM=============================================== ====================

    REM = Reactivate Database========================================== ===
    if exist "%1\DbSys\RangerMSPStop.ini" del "%1\DbSys\RangerMSPStop.ini"
    echo Database reactivated...
    REM=============================================== ====================

    :End

    Re: Automated Backup Script (OpenSource)

    Do all CommitCRM users have to be out of the system to run this script? In other words, if I schedule it to run at midnight, and everyone leaves CommitCRM open, will that be a problem?

    Sweet, thanks for the script!

    Comment


      Re: Automated Backup Script (OpenSource)

      Hi,

      Thanks for posting this question.
      The script shuts the database down by itself, so there's no need to close every RangerMSP client, or the RangerMSP Services. The backup script should run without any problems, while the clients are still on.

      However, we do suggest that the best practice is to enforce a procedure that involves shutting down any RangerMSP clients used at the end of the day; just to be safe.

      Let me know if you have anymore questions on this topic.

      Reno Breen

      Comment


        Re: Automated Backup Script (OpenSource)

        Are image based backups like Acronis not sufficient for backing up CommitCRM live using VSS?

        Comment


          Re: Automated Backup Script (OpenSource)

          Hi,

          This is an excellent question.
          In order to backup RangerMSP, the RangerMSP database must be shut down, in order to make sure that no tables are being edited at the time of the backup.

          Specifically regarding Acronis, there are 2 types of this software that can be run.

          1) If you're using the installed version that can back the system up while the operating system that houses RangerMSP is still running, then you will need to create your own script that automatically closes the database to network communications, and then reinstates the system; you can take a few sections from the script above and customize them to your businesses needs.

          2) If the Acronis software you are using is the type that you boot the server with, then the RangerMSP database has already been shut down during the windows shutdown sequence, and you can perform the Acronis backup freely by backing the RangerMSP folder up.

          Let us know if you have any questions on this topic.

          Reno Breen

          Comment


            Re: Automated Backup Script (OpenSource)

            Can I just say, as welcome as this script is its pretty clunky to have to do this to run a backup. Surely you can incorporate into CommitCRM the option for a user with sufficient privaleges to just run a backup with one click? Have a backup section where you list the desired location of the backup so you dont need to do it every time, the task also kicks everyone out and runs the backup at a scheduled time or at your press of a button. Its pretty surprising that this still isn't inCommitCRM. I cant tell you how painful and clunky it is to do a manual backup at the moment, when it should be able to be launched with a single click and some background settings. Be great to see this on the roadmap.

            Comment


              Re: Automated Backup Script (OpenSource)

              Hi Natrat,

              Thanks for the comments; i'll pass them on.

              Regards,
              Sherry

              Comment


                Re: Automated Backup Script (OpenSource)

                Does the SQL version have the same limitations in regards to not being able to be backed up live using software like Acronis or Storagecraft?

                Comment


                  Re: Automated Backup Script (OpenSource)

                  Hi Ascendnet,

                  Thanks for sending this in.
                  Yes; the SQL Database also requires shutting down the database prior to the backup, so we suggest using this software to only backup the archive created by RangerMSP or this script.

                  Alternatively, you can create your own scripts that shut down and restart the database, and use them to automatically shut the database down prior to an Acronis Image backup. Once the backup is complete, run the second script to enable the database.

                  Hope this helps.
                  Regards,
                  Sherry

                  Comment


                    Re: Automated Backup Script (OpenSource)

                    Please add my vote to make CommitCRM "VSS aware"

                    Comment


                      Re: Automated Backup Script (OpenSource)

                      +1 ^ to the VSS aware

                      Comment


                        Re: Automated Backup Script (OpenSource)

                        again on backup -

                        Implies that in order to successfully backup the entire CommitCRM server all you need to do is shutdown the services and copy the CommitCRM folders. Thats pretty much all the above script does yes? If that the case you can just use something like the free Cobian Backup which allows you to shutdown services and restart them again on completion. Fire it off in the middle of the night and you have a working backup. Or am I missing something?

                        Comment


                          Re: Automated Backup Script (OpenSource)

                          natrat, once nothing accesses the RangerMSP database you should be safe to backup the files in any way you want.
                          The nice thing with the script is that it instructs everyone to stop connecting to the database.


                          Make sure that -
                          All RangerMSP clients are stopped
                          RangerMSPWebInterface service is stopped
                          RangerMSPServer service is stopped
                          ANY third party system that uses RangerMSP's APIs to integrate is stopped

                          Back the files.

                          Done!

                          Hope this helps.
                          Dina

                          Comment


                            Re: Automated Backup Script (OpenSource)

                            I thought I'd create a small backup tool to perform CommitCRM backups a little easier.

                            Features include:
                            - backup the program directory, data directory or docs directory
                            - upload backups to an ftp server
                            - sends an email on success/failure
                            - can be scheduled to run automatically

                            download the program from http://www.smartitsupport.com/softwa...tcrm/setup.exe and let me know of any problems

                            Comment


                              Re: Automated Backup Script (OpenSource)

                              very cool, but when i tried to install, i get the following error.

                              http://i.imgur.com/A2d4d.png

                              Comment

                              Working...
                              X