Skip to main content

Rsync backup data

Tình thế là m có 1 site nhỏ cần backup data upload 1 tuần 1 lần. Data chủ yếu là ảnh, do dịch vụ Amazon S3 chát quá đành quay về dùng trên host.
- Ảnh để trong vài thư mục như quiz, answer, post, result ...
- Trong các mục trên là các mục con chia theo thời gian upload, vd 2016/01/31 hay 2016/02/14 ...
2016
.......01/
...........01/ 02/ ... 31/
.......02/
- Backup dùng rsync.
- M ko sync cả mục theo tháng là vì dung lượng lớn + với backup theo tuần.

Dùng rsync thì đơn giản là copy tất cả mục trong tuần về máy local. Vấn đề là do đường dẫn sync From dài quá nên mình quyên mất là rsync cũng như copy có thể copy nhiều thư mục về 1 chỗ.
ví dụ:
rsync --ignore-existing --recursive root@188.177.223.224:/var/www/site_release/uploads/post/2016/02/03 .

là backup đồng bộ mục ngày 3 tháng 2 về máy local.
dễ thấy đường dẫn source là rất dài. Muốn sync nhiều ngày:
rsync --ignore-existing --recursive root@188.177.223.224:/var/www/alob_release/uploads/post/2016/02/03  root@188.177.223.224:/var/www/alob_release/uploads/post/2016/02/04 root@188.1xx.223.224:/var/www/alob_release/uploads/post/2016/02/05 root@188.1xx.223.224:/var/www/alob_release/uploads/post/2016/02/07 root@188.1xx.223.224:/var/www/alob_release/uploads/post/2016/02/08 root@188.1xx.223.224:/var/www/alob_release/uploads/post/2016/02/13 root@188.1xx.223.224:/var/www/alob_release/uploads/post/2016/02/12 root@188.1xx.223.224:/var/www/alob_release/uploads/post/2016/02/14 .

Mình tính dùng for loop hoặc viết 1 file bash để tự động việc này. M sẽ update sau. Nhưng bao giờ trước khi tự động việc j cũng phải làm thủ công ok đã.

Ngoài backup Data file ra thì backup Database cũng có nhiều thứ m phải học hỏi thêm. Lý do là:
1. Khi DB quá lớn tầm > 50MB thì việc backup toàn bộ là không ổn. vd 1 tuần backup 2 lần là 100MB.
2. Khi cần dữ liệu test ví dụ một vài record kiểu bài post hay product bị lỗi, làm sao để nhanh chóng tái hiện trên môi trường local (dev) để fix. Nếu import cả DB trên production về đôi khi gặp nhiều trở ngại.
3. Tự động backup và một số vấn đề về export import...

Cuối cùng là lưu trữ backup file. Mình lưu trên máy local, trên dropbox và google drive và trên 1 hdd riêng biệt nữa. Hiện tại thì data chưa nhiều nhưng khi cỡ hàng trăm MB hay GB thì có thể phải tìm cách khác vì cloud cần đường net mạnh.



Comments

Popular posts from this blog

Rand mm 10

https://stackoverflow.com/questions/2447791/define-vs-const Oh const vs define, many time I got unexpected interview question. As this one, I do not know much or try to study this. My work flow, and I believe of many programmer is that search topic only when we have task or job to tackle. We ignore many 'basic', 'fundamental' documents, RTFM is boring. So I think it is a trade off between the two way of study language. And I think there are a bridge or balanced way to extract both advantage of two method. There are some huge issue with programmer like me that prevent we master some technique that take only little time if doing properly. For example, some Red Hat certificate program, lesson, course that I have learned during Collage gave our exceptional useful when it cover almost all topic while working with Linux. I remember it called something like RHEL (RedHat Enterprise Linux) Certificate... I think there are many tons of documents, guide n books about Linux bu

Martin Fowler - Software Architecture - Making Architecture matter

  https://martinfowler.com/architecture/ One can appreciate the point of this presentation when one's sense of code smell is trained, functional and utilized. Those controlling the budget as well as developer leads should understand the design stamina hypothesis, so that the appropriate focus and priority is given to internal quality - otherwise pay a high price soon. Andrew Farrell 8 months ago I love that he was able to give an important lesson on the “How?” of software architecture at the very end: delegate decisions to those with the time to focus on them. Very nice and straight-forward talk about the value of software architecture For me, architecture is the distribution of complexity in a system. And also, how subsystems communicate with each other. A battle between craftmanship and the economics and economics always win... https://hackernoon.com/applying-clean-architecture-on-web-application-with-modular-pattern-7b11f1b89011 1. Independent of Frameworks 2. Testable 3. Indepe