Backing up VisibleThread data
It is recommended that you back up the VisibleThread server regularly so that in the unlikely event of a system failure, or outage, the system can be restored to a stable state with minimal loss.
The VisibleThread Server contains a backup script that will backup all VisibleThread user accounts and user data. This script is useful as it takes a relatively short amount of time to run. The application does not have to be brought down to run this backup.
To run this script log on to the VisibleThread Virtual Server console and execute the following commands:
# Ubuntu
# when logged in as the visiblethread user
cd /home/visiblethread/VisibleThreadTools
./vt-backup.sh
# Ubuntu
# when logged in as any other user
cd /home/visiblethread/VisibleThreadTools
sudo -u visiblethread ./vt-backup.sh
# Red Hat
cd /opt/visiblethread/VisibletThreadTools
sudo -u visiblethread ./vt-backup.sh
# Windows
# Open command prompt
C:\Program Files\visiblethread\vtdocs\VisibleThreadTools\vt-backup.bat
Note You may be prompted for the “visiblethread” user password when running this command.
This will create a backup file in the following directory:
# Ubuntu
/home/visiblethread/VisibleThreadTools/<vtbackups>
# Red Hat
/opt/visiblethread/VisibleThreadTools/<vtbackups>
# Windows
C:\Program Files\visiblethread\vtdocs\VisibleThreadTools\vtbackups
Creating a scheduled backup of VisibleThread data
To automate the backup execute the following commands on the VM console:
- Open the crontab editor
crontab -e
- If prompted to choose an editor enter '2' for 'nano'
- The editor should load. using the cursor keys, move to the last line in the editor and enter the following:
0 0 * * 0 /home/visiblethread/VisibleThreadTools/vt-cron-backup.sh >> /tmp/visiblethread-cron.log 2>&1
- Now type CTRL-O, hit return and then CTRL-X to exit the editor.
- This has now setup a scheduled task to run at midnight each Sunday morning to run the backup.
You can change the entry above to choose whatever time interval you like for the job.
Note: This creates a log file in '/tmp/visiblethread-cron.log ' you should check this file on a regular basis to ensure there are no errors with the backup.
For more information on the format of the cron entry see this article:
https://en.wikipedia.org/wiki/Cron
Note both of these simply archive the user data and place it in the /home/visiblethread/VisibleThreadTools/vtbackups (Ubuntu) /opt/visiblethread/VisibleThreadTools/vtbackups (RedHat) directory. To ensure resiliency against VM failure, the entire VM should be backed up externally, or the backup files should be regularly ftp'd or synched off the VM to another location.
Creating a Scheduled Backup in Windows
To automate backups in Windows you must create a Scheduled Task
1. Open up the Scheduled Task program and create a Basic Task
2. Add a Name and Description
3. Add a Trigger (in this case it will run Daily)
4. Select 'Start a program' for the Action
5. Fill in the Program details
- Program/script should be: C:\Windows\System32\cscript.exe
- Add arguments should be: //nologo ".\lib\backup.vbs" -f "c:\path\to\your\backup\folder"
- Start in should be C:\Program Files\VisibleThread\vtdocs\VisibleThreadTools
6. Save the task and open up its Properties by checking Open the Properties dialog for this task when I click Finish
7. Edit the Security options and select Run whether user is logged on or not as well as Run with highest privileges. You may want to create a dedicated Service Account for this purpose.
8. Test. You should now be able to manually trigger the Scheduled Task and validate that the backup file was created in the folder you specified.
Setting up a scheduled task to retrieve backup files from the VisibleThread VM
One approach to automate the retrieval of the files created by the CRON backup (see above) is to create a scheduled task on a windows server somewhere in your network to FTP the latest cron backup from the VisbileThread server and copy it to a location on your network. You can do this using WinScp by following these steps.
- First identify the machine you wish to use to run the scheduled ftp pull request. This must be able to ping the VisbileThread server, and should be running and OS that contains the Windows Task Scheduler (e.g. Windows server)
- Install WinScp on this machine (see https://winscp.net/)
- Now startup WinScp and create a secure ftp connection for your VisibleThread server. Make sure you save the username and password for the VisibleThread server in the connection, and give the connection the name 'VisibleThreadServer'
- Test the connection by clicking 'Login'
- Once you have the FTP connection correctly defined take the attached file "vt-backup.txt" and save it on the Windows Server as "C:\VTBackups\vt-backup.js"
- Now open Windows Task Scheduler and create a new Scheduled Task Called 'VisibleThread Backup Synch'
- Under the 'Trigger' tab create a new trigger to define a schedule for this task. Give the task a schedule that corresponds with how often the CRON backup on the VisibleThreadServer will run. For example if the VisibleThreadServer backup runs at 1am every night, the windows task should run at 2am every night (to give the VisbileThread backup enough time to complete).
- Under the 'Actions' tab, create a new action and fill in the values from the screenshot below:
- Save your changes
You now have created a scheduled task that runs on your Windows server that using Secure FTP to pull down the backup file created by the CRON job on the VisibleThread server. The backup file will be placed in the c:\VTBackups folder on your Windows Server
Restoring from a backup file
To restore the VisibleThread data, execute the following scripts:
# Ubuntu
/home/visiblethread/VisibleThreadTools/vt-restore.sh /<pathtobackup>
# Red Hat
/opt/visiblethread/VisibleThreadTools/vt-restore.sh /<pathtobackup>
# Windows
C:\Program Files\visiblethread\vtdocs\VisibleThreadTools\vt-restore.bat C:\<pathtobackup>
Note You may be prompted for the “visiblethread” user password when running this command.
The <backupfile> parameter is the name of a backup file created using the ‘vt-backup’ command.