Project

General

Profile

Helper Scripts » History » Revision 11

Revision 10 (Enis Nuredini, 23.08.2023 11:16) → Revision 11/15 (Enis Nuredini, 23.08.2023 11:19)

h1. Helper Scripts 

 

 h2. Backup project folder and both DBs 

 *tear_down_project.py*   
 Functionality: Creating backup file from project folder and databases (data and typo3). Transfering files to /scratch/tmp/365/. Comprimising all files in one tar. Deleting all created files during this process (except the summary tar file). 

 Requirement: User should have ssh keys for the affected server hosts. 

 Configuration: In the top of the script the project and database host can be written. Path to the ssh keys is set as default. 

 Executed from: Own host 

 


 h2. Transfer specific records from DB1 to DB2 

 *table_groupmember_reference_transfer.py*  
 Functionality: User given argument will be searched in configured column (default: reference) from table (default: GroupMember). All found records are transfered from source DB to target DB. If record with given argument exists on target DB then UPDATE statement is executed, otherwise INSERT statement. 

 Requirement: Table structure from source and target DB must be identical. Date and datetime defaults, if nothing given in source record needs to be NULL, otherwise mysql outputs an error. 

 Configuration: DB-users, hostnames and affected table or column can be set inside the script. 

 h2. Guide to synchronize fileadmin files and transfer tables 

 *set_project_live.py - table_data_transfer.py* 
 Functionality: Numbered listing of all existing files and folders in fileadmin (depth level: 1). Ability to choose the paths which the user wants to synchronize with rsync. rsync with dry-run will be executed. Paths are filtered by existing files or folders that needs to be synced. Final rsync without dry-run will start and for every rsync user is asked if it should be executed. After fileadmin sync is finished the next script for table transfer will start automatically.    User is asked to give a comma seperated list of tables which should be transfered (overwrite) the tables on the target host.    DB dump from source and target host will be created. Affected target host tables will be truncated and overwritten with the source host table data. 

 Requirement: Both scripts needs to be in same folder and located in source server host, where the to transfered project is. Used DB-Users should have access to the databases. Source host should have ssh access to target host. 

 Configuration: Target_hostname (default: w22a), DB-users and DB-hosts (wdb16.math.uzh.ch, wdb22.math.uzh.ch) can be defined inside the script. In this example the source host was: w16