Synclivesitestoin-housedevservers_MySQL
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Synclivesitestoin-housedevservers_MySQL,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1562字,纯文字阅读大概需要3分钟。
内容图文
One of our customer found it tedious to sync his live websites to his dev servers, it involved using FTP (since he had no version control) as well as the database.The files were over 2GB by themselves, so it could be a time consuming task. As a result he asked us for a solution, and we were able to provide the following script to help him out.
Put the following into a script (eg sync.sh ), then chmod +x sync.sh
#!/bin/bash # Add your ssh key to the remote server before running this# Where are the local files going to be savedLOCALDIR=~/local/dev/www/ # No trailing / please on this one belowREMOTEDIR=/var/www/vhosts/yourdomain.co.nz/httpdocs # Remote MySQL connection detailsREMOTE_SQL_USER=databaseusernameREMOTE_SQL_PASS=JGOIDBp4553ghREMOTE_SQL_DB=databasename # Local MySQL connection detailsLOCAL_SQL_USER=databaseusernameLOCAL_SQL_PASS=JGOIDBp4553ghLOCAL_SQL_DB=databasename # Remote host IPREMOTE_HOST=49.50.242.111REMOTE_USER=root ssh ${REMOTE_USER}@${REMOTE_HOST} "mysqldump -u${REMOTE_SQL_USER} -p${REMOTE_SQL_PASS} ${REMOTE_SQL_DB} >/tmp/${REMOTE_SQL_DB}.sql" rsync -avP ${REMOTE_USER}@${REMOTE_HOST}:$REMOTEDIR/* ${LOCALDIR} rsync -avP ${REMOTE_USER}@${REMOTE_HOST}:/tmp/${REMOTE_SQL_DB}.sql /tmp/mysql -u${LOCAL_SQL_USER} -p${LOCAL_SQL_PASS} ${LOCAL_SQL_DB} < /tmp/${REMOTE_SQL_DB}.sql |
Edit the script as needed to reflect the database/files/etc you want, then run ./sync.sh
To make this really seamless, use ssh keys to login. If you want to have this on a cron, make sure you put the full path to the rsync and mysql, or any other binaries used.
内容总结
以上是互联网集市为您收集整理的Synclivesitestoin-housedevservers_MySQL全部内容,希望文章能够帮你解决Synclivesitestoin-housedevservers_MySQL所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。