DEV Community

mark vachi
mark vachi

Posted on

4 3

บันทึก: การย้าย database และ laravel storage ไปเครื่องใหม่

กำหนด

192.0.0.1 เป็นเครื่องเก่า 192.0.0.2 เป็นเครื่องใหม่ ทั้งสองเครื่องเป็น Ubuntu server ใช้ database เป็น MySQL และ web app เป็น Laravel ที่รันอยู่บน vesta

STEP 1

Export database จากเป็นเครื่องเก่า

$ mysqldump admin_database > admin_database.sql
Enter fullscreen mode Exit fullscreen mode

STEP 2

บีบอัน storge ในกรณีนี้หลาย directory ก็ระบุ path ไป

$ tar -czvf storge.tar.gz storage/app storage/excel/exports public/uploads
Enter fullscreen mode Exit fullscreen mode

STEP 3

ส่ง file ไปยังเครื่องใหม่ ผ่าน ftp protocol โดยใช้ curl วิธีนี้จะทำให้เห็น progress ว่าส่ง file ไปถึงไหนแล้ว

$ curl -T admin_database.sql ftp://192.0.0.2 --user <username>:<password>

$ curl -T storge.tar.gz ftp://192.0.0.2 --user <username>:<password>
Enter fullscreen mode Exit fullscreen mode

วิธีนี้ต้องลง ftp และเปิด port ftp ที่เครื่องใหม่ก่อน อ่านวิธีนั้นที่นี่ install-ftp-server-on-ubuntu

STEP 4

Import Database ไปยังเครื่องใหม่

$ mysql admin_database < admin_database.sql
Enter fullscreen mode Exit fullscreen mode

STEP 5

ย้าย file storge.tar.gz ไปยัง web path และ untar file

$ mv storge.tar.gz /home/admin/web/domain_name/public_html
$ cd /home/admin/web/domain_name/public_html
$ tar -xvf storge.tar.gz
Enter fullscreen mode Exit fullscreen mode

Reference

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay