User Tools

Site Tools


en:migrage-tms

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:migrage-tms [2022/03/14 14:08]
Денис Цыганов [Creating dump your DataBase]
en:migrage-tms [2025/03/05 14:41] (current)
Виталий Журавлев
Line 1: Line 1:
  
-====== Migration ​DB at TMS ======+====== Migration ​Tvip TMS between servers ​======
  
    
Line 6: Line 6:
 ===== Creating dump your DataBase ===== ===== Creating dump your DataBase =====
  
-Create dump your PostgreSQL ​Database ​with "​**pg_dump**"​ tool \\+Create dump your PostgreSQL ​database ​with "​**pg_dump**"​ tool \\
 <​code>​ <​code>​
 pg_dump --no-owner --exclude-table-data=device_stat_channel -U tvip-tms tvip-tms ​ >  /​backup/​tvip-tms.sql pg_dump --no-owner --exclude-table-data=device_stat_channel -U tvip-tms tvip-tms ​ >  /​backup/​tvip-tms.sql
 </​code>​ </​code>​
  
-:!: If you need make dumps of others ​Databases+:!: If you need make dumps of others ​databases
 <​code>​ <​code>​
 pg_dump --no-owner -U tvip-tms tvip-tms-audit >  /​backup/​tvip-tms-audit.sql pg_dump --no-owner -U tvip-tms tvip-tms-audit >  /​backup/​tvip-tms-audit.sql
Line 17: Line 17:
 </​code>​ </​code>​
  
-===== Copy dump of Databases ​to new Sever TMS =====+===== Copy dump of databases ​to new TMS server ​=====
  
-Copy Dump of Database ​to new TMS Server ​with "​**scp**"​ tool.+Copy dump of database ​to new TMS server  ​with "​**scp**"​ tool.
 <​code>​ <​code>​
 scp /​backup/​tvip-tms.sql username@host:/​backup/​ scp /​backup/​tvip-tms.sql username@host:/​backup/​
Line 25: Line 25:
  
  
-===== Creating ​Database ​ =====+===== Creating ​database ​ =====
  
 Before install TVIP TMS, you should install PostgreSQL and restore dump of Database.\\ Before install TVIP TMS, you should install PostgreSQL and restore dump of Database.\\
Line 39: Line 39:
 </​code>​ </​code>​
  
-  * Create databasetvip-tms with user: tvip-tms+  * Create ​user tvip-tms and database tvip-tms with owner tvip-tms
 <​code>​ <​code>​
-sudo -u postgres psql +su -c "createuser tvip-tms && createdb -O tvip-tms tvip-tms" postgres
-createuser tvip-tms && createdb -O tvip-tms tvip-tms+
-\q+
 </​code>​ </​code>​
  
Line 49: Line 47:
 :!: If you use other databases then create them: :!: If you use other databases then create them:
 <​code>​ <​code>​
-sudo -u postgres psql +su -c "createdb -O tvip-tms tvip-tms-audit" postgres 
-createdb -O tvip-tms tvip-tms-audit; +su -c "createdb -O tvip-tms tvip-tms-vod" postgres
-createdb -O tvip-tms tvip-tms-vod+
-\q+
 </​code>​ </​code>​
  
-===== Restore the Dump of Database ​===== +===== Restore the dump of database ​===== 
-  * Restore the Dump of Database:+  * Change auth method to postgres: 
 +<​code>​ 
 +sed -i /​etc/​postgresql/​*/​main/​pg_hba.conf -e "​s|local ​  ​all ​            ​all ​                                    ​peer|local ​  ​all ​            ​all ​                                    ​trust|"​ 
 +sed -i /​etc/​postgresql/​*/​main/​pg_hba.conf -e "​s|host ​   all             ​all ​            ​127.0.0.1/​32 ​           md5|host ​   all             ​all ​            ​127.0.0.1/​32 ​           trust|"​ 
 +systemctl reload postgresql  
 +</​code>​ 
 +  * Restore the dump of database:
 <​code>​ <​code>​
 psql -U tvip-tms tvip-tms ​ < /​backup/​tvip-tms.sql psql -U tvip-tms tvip-tms ​ < /​backup/​tvip-tms.sql
Line 64: Line 66:
 <​code>​ <​code>​
 psql -U tvip-tms tvip-tms psql -U tvip-tms tvip-tms
-update device set authkey = ''​;+update device set authkey = null;
 \q \q
 </​code>​ </​code>​
 +
 +=====  Creating and restoring a MongoDB backup =====
 +
 +Create a backup copy of the MongoDB database, using the utility **mongodump**
 +
 +<​code>​
 +mongodump --db images --gzip --archive > /​mongoBackup/​images.dump.gz ​
 +</​code>​
 +
 +Install the MongoDB database on the new server:
 +
 +<​code>​
 +# apt install mongodb-org
 +# systemctl start mongod.service
 +# systemctl enable mongod.service
 +</​code>​
 +
 +Restore a MongoDB backup, using the utility **mongorestore**
 +
 +<​code>​
 +mongorestore --gzip --archive=/​mongoBackup/​images.dump.gz  ​
 +</​code>​
 +
 +:!: If you want to keep statistics, save and restore a backup for the database **content**
 +
 +<​code>​
 +mongodump --db content --gzip --archive > /​mongoBackup/​content.dump.gz ​
 +mongorestore --gzip --archive=/​mongoBackup/​content.dump.gz
 +</​code>​
 +
 +
 ===== Deploy new TMS ===== ===== Deploy new TMS =====
  
Line 90: Line 123:
  
 ===== Post migration procedure ===== ===== Post migration procedure =====
- +<WRAP center round important 60%> 
-  ​* ​Enable "Allow quick biding​" ​for your Provider \\+Enable "Allow quick binding​" ​option on provider settings. Quick binding option allow authorization device without ask login/​password. 
 +</​WRAP>​
   * Change ip of server or change DNS record to route clients to new TMS.\\   * Change ip of server or change DNS record to route clients to new TMS.\\
en/migrage-tms.1647256126.txt.gz · Last modified: 2022/03/14 14:08 by Денис Цыганов