Tutorial Office to Office Sync

rev 1.003, 19.10.24

How to read this tutorial



Summary

This tutorial is targeted:


Wishing to:


This guide is a complete walkthrough covering:


Scenario



Your task would be to make sure people in London have a subset of your files (i.e. a project folder) to work on, having the same paths as on main premises, for easy sync and pick up of work project files. Instead of having to manually copy files forth and back, we collect the files needed to copy and submit a transfer job to Accsyn using a custom made button in user application.

IMPORTANT NOTE: The terms mentioned/configuration steps outlined below are described in detail in our Accsyn Admin Manual, for instructions on how to use the Accsyn desktop app - have a look at the Accsyn User Manual. Always consult the manuals before your reach out to support@accsyn.com.


Installing Accsyn


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


By now you have a fully working file transfer solution that can be used by external user to receive and send back large file packages at high speed (i.e. an accelerated encrypted FTP server replacement). We are now going to continue and make file transfers submitted by Python scripts to enable an automised workflow.


Configuring site to site


Configuring remote site


Installing daemon (server) at remote site

 To be able to sync files at remote site, we need to add install a server on a computer that has access to local site storage. We assume the storage is mounted @ "/mnt/projects" here aswell, and the hostname of computer is "beta":


Setting up server IP overrides

Now we are almost done. Accsyn attempts to connect using Internet WAN IP addresses, but we want to direct the traffic over our dedicated VPN trunk. To achieve this, we need to configure Accsyn accordingly:


Setting up hook

In this tutorial we also describe the optional step of enabling atomisations, this is done by defining a "hook" within Accsyn that is run whenever a transfer job is finished.


Each time a job finishes from now on, your script will be called with a path to a job description JSON as argument #1. You can open this job description JSON to find out information about the job, enabling you to for example submit a chained job to Accsyn or perform other workflow atomisations.

 Note: Jobs will fail if the hook fails to execute. If you have standard transfers that should not be processed by the hook, create a separate queue and configure hooks for that queue instead. Then submit jobs to that queue, this will have standard transfer jobs go outside your workflow and ignore hook.


Copying files from main site to remote site


We assume you have decided to copy the following files to remote site for users to start working on:

 /mnt/projects/_LIBRARY/statistics.zip    (file)

 /mnt/projects/XFC001/London  (directory)

Sending an E-mail to admins plus additional recipient "john@medtech.co.uk" when transfer is done.


Submitting the job to Accsyn using desktop app



Submitting the job to Accsyn using CLI or Python API


Besides using the Accsyn desktop app to send files, jobs can be submitted using the CLI and the Python API.


Submitting using CLI

The simplest approach is to open a shell and submit using our CLI with RSYNC notation:

accsyn --mail john@medtech.co.uk  medtech:/mnt/projects/_LIBRARY/statistics.zip medtech:/mnt/projects/XFC001/London  site=london

Note: Assuming "accsyn" is in your path, default full path would be "/usr/local/accsyn/accsyn" otherwise.


Submitting JSON using CLI

 JSON format for submit through CLI and Python API. Save this to temporary file, for example  /tmp/accsyn/jobsubmit/A5F1D.json :

{

        "code":"XFC001 data sync to London", 

        "mail":"john@medtech.co.uk",

        "tasks":{

                "0":{

                      "source":"medtech:/mnt/projects/_LIBRARY/statistics.zip",

                      "destination":"site=london"

                },

                "1":{

                       "source":"medtech:share=projects/XFC001/London",

                       "destination":"site=london"

                }

        }

}

Note: The syntax of second file shows how a named share can be given instead of absolute path.

accsyn /tmp/accsyn/jobsubmit/A5F1D.json


You should get an E-mail notification that job has been submitted. The transfer job will appear in desktop app and be listable in CLI. 

accsyn job find


To look for clues why job is not starting or possible errors during transfer, double-click job in desktop app and sift through the logs that opens when clicking the magnifier glass icon on a file/task. Or using the CLI:

accsyn job report <ID>



Using Python API

For instructions on how to use our Python API, please head over to: Accsyn Python API Documentation.


import accsyn_api

session = accsyn_api.Session(domain="medtech",username="andrea@medtech.de",api_key="****")

job = session.create("job","/tmp/accsyn/jobsubmit/A5F1D.json")


Print job status:

print session.str(session.find_one("job where id=%s"%job["id"]))


To add file to an existing job:

session.create("task", {"tasks":["share=projects/_REF/simulations.mov"]}, job["id"])

Or if renaming needed:

session.create("task", {"tasks":[{"source":"share=projects/_REF/simulations.mov","destination":"share=projects/TMP/simulations_tmp.mov"}]}, job["id"])


Note: If you tend to submit many jobs, attempt to re-use a job and add files as described above. In that case, we do not want an E-mail sent everytime job finished - submit job with ..,"email":"none",... supplied.


Syncing files back

To sync back files from remote office simply reverse the source and destination parties:

{

        "code":"XFC001 data sync from London to HQ", 

        "tasks":{

                "0":{

                      "source":"site=london:/mnt/projects/XFC001/London/Output_2608-2019",

                      "destination":"medtech" 

                }

        }

}



Voila, you should be all setup with Accsyn!