Tutorial - Scripted Backup

Rev 1.002, 2022.11.17

How to read this tutorial

  • The tutorial does not cover all features of accsyn, just a selected set.

  • Entries in Bold are highlighted important input data.

  • Entries in Bold Italic are made up data for this tutorial only, here you provide your own data as appropriate.

  • Labels in Italic correspond to the name of an input were you enter data.

  • Text in [ BRACKETS ] denotes a button within user interface, were LINK points out a link - for example a navigation link.

Summary

This tutorial is targeting organisations that has on-prem or cloud project storage, typically a file server with an attached RAID disk system.


Wishing to:

  • Have fast and secure backup of project data to a remote storage, typically a non expensive Linux server or a NAS.

  • Have backup to run automatically once a day.

  • Be able to monitor and modify the backup using a simple web browser.

  • Enable employees to restore from backup as needed.


This tutorial is a complete walkthrough covering:

  • Setting up accsyn at hq (on-prem/cloud).

  • Setting up accsyn at a remote site/location.

  • Setting up the Python environment on server to enable script execution.

  • Building and saving the backup script.

  • Test run and validate the script.

  • Configure server to run backup script at 00.00 every night.


Notes:

  • In this tutorial we are only covering setting up a backup behaviour, accsyn can also act as a replacement of your current SFTP server and many other things, please visit accsyn.com for full feature specifications.

  • accsyn does NOT store incremental backup sets like for example Apple Timemachine or commercial backup softwares do, this means if a file is deleted and backed up there will not be older versions for recovery. A good practice is to setup a secondary weekly or monthly backup to a separate site, in order to recover deletions.


Source code downloadable here:

Schematics

Installing and configuring accsyn on/prem or cloud


The following guide is a short summary of the installation process described in detail here: accsyn Admin Manual

  • Register your Email (admin@company.com) and domain @ https://customer.accsyn.com, we recommend using the same accsyn domain name as you have with Ftrack. In this tutorial we will use company(.accsyn.com).

  • Follow the guide to initialise domain. Hint: Read through the admin tour when offered, it gives insight into the architecture of accsyn and the terms used/names of entities.

  • Install server; when the guide instructs you to install the accsyn daemon, download and install it on your current file transfer on-prem server ("alpha"). Pick a server that has access to your storage, or a the part of your storage that you want to expose to accsyn.

  • Network; the guide will ask you to configure your firewall, add NAT port forwards 45190-45210 (tcp) to file transfer server "alpha". Note that accsyn daemon DOES NOT listen to any ports 24/7, it will only start a listening process during file transfer init, software firewalled to accept incoming connections from remote client WAN IP only. For more information, please refer to accsyn Security Whitepaper.

  • Root share; Browse to your storage, were project store resides. In this tutorial, we assume server is running Windows and have project data accessible/mounted at D:\projects (Linux path /mnt/projects).

  • Finish installation.


You now possess a fully functional file sharing service that can act as an replacement for example a FTP server.


Installing accsyn on a remote site/location

Next, we are going to setup the remote backup site. In this tutorial we are going to name it "backup" and we assume you have prepared a local Linux server with proxy storage mounted at same path as main server (/projects):

  1. Logon to accsyn as an administrator.

  2. Go to admin>Sites and choose [Create site].

  3. Enter the name (code) of site (backup) and click [Create].

  4. Go to admin>Servers and choose [Install server].

  5. Choose "Serving root share(s) on a remote site." option, choose the site (backup) and the root share (projects).

  6. Click Next.

  7. Conclude the server installation by installing the accsyn Daemon on the backup computer/NAS, authenticating and finish server installation.


You now have a fully working setup were you can manually push files to backup sites, we are now going to set up automatic backup through a Python script.

Preparing Python on server


Install Python


In this tutorial, we run the script with Python 3. Python 2 can be used aswell.

  1. Logon to the server as an administrator.

  2. Download and install Python 3 (https://www.python.org/downloads/), record install location for later.

  3. Download Pip installer (get-pip.py) from https://pip.pypa.io/en/stable/installing/.

  4. Install Pip, open a DOS prompt were you downloaded the installer and run "<path to Python 3 install location>\python get-pip.py".


Install accsyn Python API and dependencies


  1. Open a DOS prompt and run <path to Python 3 install location>\Scripts\pip install requests accsyn-python-api.


Getting boilerplate backup script


We provide a boilerplate Python 3 script at our GitHub: https://github.com/accsyn/scripted-backup. Download it and place locally, assuming your username is "admin": "C:\Users\Admin\Documents\backup.py".

Configure backup script

This part requires you have some basic understanding of the Python language.


Modifying script to your needs


  1. Open the script in a text editor of choice, for example Wordpad.

  2. Change PROJECTS_PATH variable value to "D:\\projects".

  3. Change the PROJECT_DATA contents, or replace it with code that fetches project information through some REST API or system call. Or your can use the commented out code within script that harvests project data by looking at disk.

  4. Save the script.


Create a launcher


The accsyn Python API requires authentication, save a file "backup.bat" alongside Python script with following content (entries in bold to be changed):


set ACCSYN_DOMAIN=company

set ACCSYN_API_USER=admin@company.com

set ACCSYN_API_KEY=57c0e2de-de50-4115-afda-348dfb4462c7

<path to Python 3 install location>\python c:\Users\Admin\Documents\backup.py


Hints:

  • Register a separate user in accsyn with employee role and use its credentials for scripting, this way you protect your account in case the sensitive API KEY gets compromised.

  • Fetch your API key by logging on to accsyn web console (https://<yourdomain>.accsyn.com) and opening your profile(account), or from the accsyn Desktop app within Preferences.


Test the backup script


We are now ready to test if the backup script works as expected:

  1. Open a DOS prompt.

  2. Run the backup launcher @ "c:\Users\Admin\Documents\backup.bat". It should tell you backup job were submitted to accsyn.

  3. Login to the remote backup site server and verify that projects where synchronised properly, check your Email for a backup job delivery confirmation message.

  4. Open the accsyn desktop app to go through the job logs and restore (site upload) files from backup.

  5. Add another project with a dummy file and run the script again, the project folder should have been synchronised accordingly.

  6. Try do inactivate/delete the dummy project, the directory should disappear at remote backup site.

Configure script to run regularly


Schedule backup


To enable automatic backup every night, we configure the Windows server to execute our backup script each day at midnight:


  1. Open a DOS prompt as an administrator (Start>Run "CMD", hit CTRL+ENTER and approve UAC prompt).

  2. Run the following command: "C:\Users\Admin\Documents>schtasks /CREATE /SC DAILY /TN accsyn_backup /TR C:\Users\Admin\Documents\backup.bat /ST 00:00". It should tell you task were added successfully.


Remove scheduled backup


  1. Open a DOS prompt as an administrator (Start>Run "CMD", hit CTRL+ENTER and approve UAC prompt).

  2. Run the following command: "schtasks /DELETE /F /TN accsyn_backup".



Conclusion

Using accsyn for backups is an effective way of running project backups, utilising the full network bandwidth with full encryption. With the possibility for users to restore lost files by themselves, you as an administrator is relieved of additional daily duties.


Automated backup job setups are often forgotten and if they stop work, you might miss out on it. With accsyn, you get Email notifications and can easily logon using the mobile friendly web application to verify that backup has executed.