blog post

1.take dump form postgresql table in csv file by shel script
2.transfer these csv to another server by shel script (crone job)
3 import these csv in mysql database


on postgressql server script configuration details with crontab seeting
shell script for apple_6s_plus table to make data csv for select date
................................. ## Querry for data without time stamp in filename.
psql -P format=unaligned -P tuples_only -P fieldsep=\, -c "select * from apple_6s_plus where sell_date = date(now())" > "../exported-data/mpl_apple_6s_plus_Table.csv" -U mpl -d mpl

apple_6s_plus.sh (END)
................................................
shell script for apple_6s_plus_featur table data corresponding to apple_6s_plus for select sell_date

-- #!/bin/sh
psql -P format=unaligned -P tuples_only -P fieldsep=\, -c " select bv.* from apple_6s_plus_featur bv left join apple_6s_plus b on b.iphone_id = bv.iphone_id where b.sell_date = date(now())" > "../exported-

data/mpl_apple_6s_plus_featur_Table.csv" -U mpl -d mpl apple_6s_plus_featur.sh (END)
.................................... script for apple_portfolio table data
#!/bin/sh
psql -P format=unaligned -P tuples_only -P fieldsep=\, -c "select p.portfolio_id,p.portfolio,p.customer_id,p.state_id,p.balance,p.updated_balance,p.direct_trading from apple_portfolio p" > "../exported-data/mpl_apple_portfolio_Table.csv" -U mpl -d mpl
apple_portfolio.sh (END)
............................................ script for common -- call aii making csv
#!/bin/bash
cd /home/mpl/mk/script-export
sh apple_6s_plus.sh
sh apple_6s_plus_featur.sh
sh apple_portfolio.sh
exit
mk_csv.sh (END)
.................................... script for drop all csv file
#!/bin/sh
rm -rf /home/mpl/mk/exported-data
mv_csv.sh (END)
.................. crontab Schedule...
50 09 * * * sh /root/cache_clear.sh
00 13 * * * sh /home/mpl/mk/script-export/mk_csv.sh
15 13 * * * sh /home/mpl/mk/script-export/mv_csv.sh

2.transfer these csv to another server by below shel script (crone job)
#!/bin/bash
rsync -auzP root@154.zzz.xxx.yyy:/home/exported-data/ /home/DATA/current/
~ 3 import these csv in mysql database

Data migration from postgresql to Mysql
  • Share This Story


Pleas give your valuable comments to improve the contents.

about author

MONU KUMAR VERMA


I'm Monu Kumar Verma, working as a Mysql DBA with over 5.9 years of experience.Database Migration,Replication,Optimization,Backup Recovery ,Tunning,Upgradation,Partitioning is part of DBA profile.
Visit Profile

Comments (1)

  • Atul Kumar Shukla

    Wednesday, 20 July, 2016 08:56 AM

    Thank you @monu for sharing post

Leave a comment

Name
E-mail
Url
Message

Get More Stuff
Subscribing to the TheOneblogs newsletter and get intersting stuff and updates to your email inbox.
Your Email

 

Style Switcher

Change Color

×! We use cookies to improve your user experience. More information