Package: db-sync-tool-kmi
db sync toolPython script to synchronize a database from an origin to a target system with automatic database credential extraction depending on the selected framework.FeaturesDatabase syncfrom and to a remote systemMySQL(>= 5.5)MariaDB(>= 10.0)Proxy modebetween two remote systemsSeveralsynchronisation modesAutomatic databasecredential extractionusing a supported frameworkTYPO3(>= v7.6)Symfony(>= v2.8)Drupal(>= v8.0)Wordpress(>= v5.0)Laravel(>= v4.0)Easily dump creation (databasebackup)Cleanupfeature for backupsExtendedloggingcapabilitiesMany more possibilities forcustomizationInstallationPrerequisiteThe script needspython3.5or higher. It is necessary for some additional functionalities to havepipinstalled on your local machine.pipThe library can be installed fromPyPI:$pip3installdb-sync-tool-kmicomposerWhile using the script within the PHP framework context, the script is available viapackagist.orgusing composer:$composerrequirekmi/db-sync-toolAdditionally install the python requirements via the following pip command:$pip3install-evendor/kmi/db-sync-tool/QuickstartDetailed instructions for:Manual database syncTYPO3 database syncSymfony database syncDrupal database syncWordpress database syncIf you want to have an inside in more configuration examples, see thetest scenarios.UsageCommand lineRun the python script via command line.Installed viapip:$db_sync_toolInstalled viacomposer:$python3vendor/kmi/db-sync-tool/db_sync_toolShell argumentsusage:db_sync_tool[-h][-fCONFIG_FILE][-v][-y][-m][-dr][-iIMPORT_FILE][-dnDUMP_NAME][-kdKEEP_DUMP][-oHOST_FILE][-lLOG_FILE][-cd][-taTABLES][-r][-tTYPE][-tpTARGET_PATH][-tnTARGET_NAME][-thTARGET_HOST][-tuTARGET_USER][-tpwTARGET_PASSWORD][-tkTARGET_KEY][-tpoTARGET_PORT][-tddTARGET_DUMP_DIR][-tkdTARGET_KEEP_DUMPS][-tdnTARGET_DB_NAME][-tdhTARGET_DB_HOST][-tduTARGET_DB_USER][-tdpwTARGET_DB_PASSWORD][-tdpoTARGET_DB_PORT][-tadTARGET_AFTER_DUMP][-opORIGIN_PATH][-onORIGIN_NAME][-ohORIGIN_HOST][-ouORIGIN_USER][-opwORIGIN_PASSWORD][-okORIGIN_KEY][-opoORIGIN_PORT][-oddORIGIN_DUMP_DIR][-okdORIGIN_KEEP_DUMPS][-odnORIGIN_DB_NAME][-odhORIGIN_DB_HOST][-oduORIGIN_DB_USER][-odpwORIGIN_DB_PASSWORD][-odpoORIGIN_DB_PORT][-fpw][-ur][-uroUSE_RSYNC_OPTIONS][origin][target]Atoolforautomaticdatabasesynchronizationfromandtohostsystems.

positionalarguments:originOrigindatabasedefinedinhostfiletargetTargetdatabasedefinedinhostfile

optionalarguments:-h,--helpshowthishelpmessageandexit-fCONFIG_FILE,--config-fileCONFIG_FILEPathtoconfigurationfile-v,--verboseEnableextendedconsoleoutput-y,--yesSkippinguserconfirmationfordatabaseimport-m,--muteMuteconsoleoutput-dr,--dry-runTestingprocesswithoutrunningdatabaseexport,transferorimport.-iIMPORT_FILE,--import-fileIMPORT_FILEImportdatabasefromaspecificfiledump-dnDUMP_NAME,--dump-nameDUMP_NAMESetaspecificdumpfilename(defaultis"_[dbname]_[date]")-kdKEEP_DUMP,--keep-dumpKEEP_DUMPSkippingtargetimportofthedatabasedumpandsavingtheavailabledumpfileinthegivendirectory-oHOST_FILE,--host-fileHOST_FILEUsinganadditionalhostsfileformerginghostsinformationwiththeconfigurationfile-lLOG_FILE,--log-fileLOG_FILEFilepathforcreatingaadditionallogfile-cd,--clear-databaseDroppingalltablesbeforeimportinganewsynctogetacleandatabase.-taTABLES,--tablesTABLESDefiningspecifictablestoexport,e.g.--tables=table1,table2-r,--reverseReverseoriginandtargethosts-tTYPE,--typeTYPEDefiningtheframeworktype[TYPO3,Symfony,Drupal,Wordpress]-tpTARGET_PATH,--target-pathTARGET_PATHFilepathtotargetdatabasecredentialfiledependingontheframeworktype-tnTARGET_NAME,--target-nameTARGET_NAMEProvidinganameforthetargetsystem-thTARGET_HOST,--target-hostTARGET_HOSTSSHhosttotargetsystem-tuTARGET_USER,--target-userTARGET_USERSSHuserfortargetsystem-tpwTARGET_PASSWORD,--target-passwordTARGET_PASSWORDSSHpasswordfortargetsystem-tkTARGET_KEY,--target-keyTARGET_KEYFilepathtoSSHkeyfortargetsystem-tpoTARGET_PORT,--target-portTARGET_PORTSSHportfortargetsystem-tddTARGET_DUMP_DIR,--target-dump-dirTARGET_DUMP_DIRDirectorypathfordatabasedumpfileontargetsystem-tkdTARGET_KEEP_DUMPS,--target-keep-dumpsTARGET_KEEP_DUMPSKeepdumpfilecountfortargetsystem-tdnTARGET_DB_NAME,--target-db-nameTARGET_DB_NAMEDatabasenamefortargetsystem-tdhTARGET_DB_HOST,--target-db-hostTARGET_DB_HOSTDatabasehostfortargetsystem-tduTARGET_DB_USER,--target-db-userTARGET_DB_USERDatabaseuserfortargetsystem-tdpwTARGET_DB_PASSWORD,--target-db-passwordTARGET_DB_PASSWORDDatabasepasswordfortargetsystem-tdpoTARGET_DB_PORT,--target-db-portTARGET_DB_PORTDatabaseportfortargetsystem-tadTARGET_AFTER_DUMP,--target-after-dumpTARGET_AFTER_DUMPAdditionaldumpfiletoinsertaftertheregulardatabaseimport-opORIGIN_PATH,--origin-pathORIGIN_PATHFilepathtoorigindatabasecredentialfiledependingontheframeworktype-onORIGIN_NAME,--origin-nameORIGIN_NAMEProvidinganamefortheoriginsystem-ohORIGIN_HOST,--origin-hostORIGIN_HOSTSSHhosttooriginsystem-ouORIGIN_USER,--origin-userORIGIN_USERSSHuserfororiginsystem-opwORIGIN_PASSWORD,--origin-passwordORIGIN_PASSWORDSSHpasswordfororiginsystem-okORIGIN_KEY,--origin-keyORIGIN_KEYFilepathtoSSHkeyfororiginsystem-opoORIGIN_PORT,--origin-portORIGIN_PORTSSHportfororiginsystem-oddORIGIN_DUMP_DIR,--origin-dump-dirORIGIN_DUMP_DIRDirectorypathfordatabasedumpfileonoriginsystem-okdORIGIN_KEEP_DUMPS,--origin-keep-dumpsORIGIN_KEEP_DUMPSKeepdumpfilecountfororiginsystem-odnORIGIN_DB_NAME,--origin-db-nameORIGIN_DB_NAMEDatabasenamefororiginsystem-odhORIGIN_DB_HOST,--origin-db-hostORIGIN_DB_HOSTDatabasehostfororiginsystem-oduORIGIN_DB_USER,--origin-db-userORIGIN_DB_USERDatabaseuserfororiginsystem-odpwORIGIN_DB_PASSWORD,--origin-db-passwordORIGIN_DB_PASSWORDDatabasepasswordfororiginsystem-odpoORIGIN_DB_PORT,--origin-db-portORIGIN_DB_PORTDatabaseportfororiginsystem-fpw,--force-passwordForcepassworduserquery-ur,--use-rsyncUsersyncastransfermethod-uroUSE_RSYNC_OPTIONS,--use-rsync-optionsUSE_RSYNC_OPTIONSAdditionalrsyncoptions-wWHERE,--whereWHEREAdditionalwhereclauseformysqldumptosynconlyselectedrows,e.g.--where="deleted=0"-amoOPTIONS,--additional-mysqldump-optionsOPTIONSAdditionalwhereclauseformysqldumptosynconlyselectedrows,e.g.--where="deleted=0"If you haven't declared a path to a SSH key, during the script execution you are requested to enter the SSH password for the given user in the shell argument or theconfig.jsonto enable a SSH connection for the remote system.ImportYou can import the python package and use them inside your project:fromdb_sync_toolimportsyncif__name__=="__main__":sync.Sync(config={},args*)ConfigurationYou can configure the script withshell argumentsor using a separate configuration file.Configuration FileTheconfig.jsoncontains important information about the origin and the target system. In dependence on the given configuration thesynchronisation modeis implicitly selected.Example structure of aconfig.ymlfor a Symfony system in receiver mode (pathdefines the location of the Symfony database configuration file):type:Symfonyorigin:host:192.87.33.123user:ssh_demo_userpath:/var/www/html/project/shared/.envtarget:path:/var/www/html/app/.envIt is possible to adjust theconfig.ymlconfiguration.File syncThere is an addon script available to sync files to. Use thefile-sync-toolto easily transfer files between origin and target system.Release GuideA detailed guide is available to release a new version. Seehere.TestsA docker container set up is available for testing purpose. Seehere.SupportIf you like the project, feel free to support the development.