Package: copyxnat
CopyXnatA utility for downloading or copying projects between XNAT servers.This is aprerelease. It may not work as intended, and may lead to data loss.
Please use caution when running on production serversQuick startPlease make sure your XNAT archive and PostgreSQL database are fully backed up before running
CopyXnat on a real XNAT server. CopyXnat may modify and overwrite your data.Install and run using pipPython 2.7 or 3.6+ is required, and pip should be installed.It is recommended that you do not modify your system Python installation. Use a tool such
as Homebrew (macOS) to install the latest python version without affecting your system python.
Then, create a dedicated virtual python environment using virtualenv and virtualenvwrapper or
similar tools.Once you have a suitable python environment set up, install with pip:pip install copyxnat --upgrade
    copyxnat --helpYou can use pip's--userflag to install dependencies in the user space instead of globally.Install and run using DockerIf you have Docker installed you can run CopyXnat in a container.
Note that interactive mode (-it) is generally required in order to enter server passwords where
prompted.docker run --rm -it tomdoel/copyxnat --helpExample use casesShow project contentsPrint a list of projects, subjects etc on an XNAT servercopyxnat show -s "https://YOUR-SERVER-URL" -u "YOUR-USER-NAME"Show differences between two projectscopyxnat compare --src-host "https://SOURCE-SERVER-URL" --src-user "XNAT-USER-SOURCE" --project "PROJECT-NAME-SRC:PROJECT-NAME-DST" --dst-host "https://DEST-SERVER-URL" --dst-user "XNAT-USER-DEST"Download projectsDownload XNAT projects onto your computercopyxnat export --src-host "https://YOUR-SERVER-URL" --src-user "YOUR-USER-NAME" --project "PROJECT1,PROJECT2"Download all projects you have access to onto your computercopyxnat export --src-host "https://YOUR-SERVER-URL" --src-user "YOUR-XNAT-USER-NAME"Copy projects from one XNAT server to anotherDuplicate a project on a destination servercopyxnat copy --src-host "https://SOURCE-SERVER-URL" --src-user "XNAT-USER-SOURCE" --project "PROJECT-NAME" --dst-host "https://DEST-SERVER-URL" --dst-user "XNAT-USER-DEST"Duplicate a project and renamecopyxnat copy --src-host "https://SOURCE-SERVER-URL" --src-user "XNAT-USER-SOURCE"  --project "PROJECT-NAME:NEW-PROJECT-NAME" --dst-host "https://DEST-SERVER-URL" --dst-user "XNAT-USER-DEST"Duplicate a project on the same server (with a new name)copyxnat copy --src-host "https://SERVER-URL" --src-user "XNAT-USER-SOURCE"  --project "PROJECT-NAME:NEW-PROJECT-NAME" --dst-host "https://SERVER-URL" --dst-user "XNAT-USER-DEST"MaintenanceRebuild catalog for all experimentscopyxnat rebuild-catalog -s "https://YOUR-SERVER-URL" -u "YOUR-USER-NAME"Reset OHIF viewer for all experimentscopyxnat ohif -s "https://YOUR-SERVER-URL" -u "YOUR-USER-NAME"Command-line parametersThe parameters vary depending which command you are running.
To see help for a particular command, run with the command name and--help, for example:copyxnat copy --helpParameterShort formDefaultDescriptionNotes--help-h-Shows general helpcommand--helpcommand-h-Shows detailed help for this command--version-Shows version numbercommand-Command to run. One ofcopy,export,show,compare,check-datatypes,ohif,rebuild-catalogSee above for examples of each command.--src-hosthostname-s-hostname of source XNAT server--src-userusername-u-XNAT username for source server--projectproject_string-pall projectslist of project IDs to processUse a colon if you want to rename project IDs between source and destination servers, egsrcId:dstId. To process multiple projects, separate the IDs with commas, egproj1,proj2. Do not include any spaces. You can do both, e.g.prj1,prj2:dst2,prj3--dst-hosthostname-d-hostname of destination XNAT serverOnly for some commands--dst-userusername-w-XNAT username for destination serverOnly for some commands--fix-scan-types-fFalseFix undefined scan types on the copyIf the source server does not correctly specify the scan type, CopyXnat will attempt to determine the scan type and set it on the destination server--transfer-modemode-tfileSpecifies how files will be copied or downloaded. One offile,zip,meta,rsyncfileto copy one file at a time.zipto zip up each resource collection as a zip file (generally faster).metato transfer metadata only, not resource files.rsyncto transfer files using rsync (experimental)--limit-subjectslimit-lno limitProcess a maximum number of subjects specified by the integerlimit.During a copy, the limit will exclude subjects which already exist on the destination and have not changed.--skip-existing-nFalseOnly copy new experiments; do not synchronise existing experimentsSpeeds up copying process when some experiments have already been copied to the destination server. However will not copy over new scans and resources that have been added to existing experiments.--verbose-vFalseOutput additional informationFor debugging and for providing additional information about what the command is doing.--insecure-kFalseDo not verify server certificatesDo not use in production as is vulnerable to MITM. For testing or working with self-signed certificates within a secure private network.--dry-run-yFalseDo not make changes on the destination serverUseful for seeing what changes a command may make before running it for real. May cause errors in some commands because the expected changes on the destination server didn't happen.--overwrite-existing-oFalseOverwrite existing data on the destination serverWhen copying, will modify and overwrite existing data--ohif-rebuild-gFalseWhen copying, trigger an OHIF viewer rebuild after each experiment copy.The OHIF Viewer does not always detect new data being added to existing experiments. This will cause a session rebuild when data are copied, but this will take additional time.--rsync-src-user-i-ssh source server username for copy via rsyncExperimental. Only used for copy using--transfer-mode rsync--rsync-dst-user-w-ssh destination server username for copy via rsyncExperimental. Only used for copy using--transfer-mode rsyncSupported XNAT data levelsCopyXnat can process the following XNAT data hierarchies.ProjectsProject ResourcesSubjectsSubject ResourcesExperimentsExperiment ResourcesScansScan ResourcesAssessorsAssessor In-Resources (copy not supported)Assessor Out-ResourcesReconstructions (copy not supported)Reconstruction In-ResourcesReconstruction Out-ResourcesCurrent limitationsReconstructions can be downloaded but cannot be copied to another serverAssessor In-Resources can be downloaded but cannot be copied to another serverSupport for eCat files is limited and untestedUsing CopyXnat in your own codeImporting via pipYou can import and run the module withpipand then import from your codefromcopyxnat.xnat.run_commandimportrun_commandfromcopyxnat.commands.show_commandimportShowCommandresult=run_command(command=ShowCommand,src_host=src_host,src_user=src_user,src_pw=src_pw,project_filter=None)Local development: running the command-line utility directlyYou can run directly from the source code. This is primarily useful if you are modifying the code.pip install -r requirements-dev.txt
   python copyxnat --helpLinksDocumentationSource codePyPiDocker HubAuthorsTom DoelCopyrightCopyright 2021 Tom DoelLicenseThis project is released under the MIT License. Please see thelicense filefor details.