备份 django 项目的最佳方法是什么?
我维护着几个低流量网站,这些网站有合理的用户上传媒体文件和半大型数据库。我的目标是将所有不受版本控制的数据备份到一个中心位置。
我当前的方法 目前
,我使用每晚的 cronjob,它使用 dumpdata 将所有数据库内容转储到项目子目录中的 JSON 文件中。上传的媒体已位于项目目录中(在 media
中)。
转储数据库后,使用 rdiff-backup(进行增量备份)将文件复制到另一个位置。然后,我使用 rsync 定期下载 rdiff-backup 目录以存储本地副本。
你的想法?
你用什么来备份你的数据?请发布您的备份解决方案 - 如果您的网站每天只有几次点击,或者您通过共享数据库和多个文件服务器保持高流量:)
感谢您的输入。
I maintain a couple of low-traffic sites that have reasonable user uploaded media files and semi big databases. My goal is to backup all the data that is not under version control in a central place.
My current approach
At the moment I use a nightly cronjob that uses dumpdata
to dump all the DB content into JSON files in a subdirectory of the project. The media uploads is already in the project directory (in media
).
After the DB is dumped, the files are copied with rdiff-backup
(makes an incremental backup) into another location. I then download the rdiff-backup directory on a regular basis with rsync
to store a local copy.
Your Ideas?
What do you use to backup your data? Please post your backup solution - if you only have a few hits per day on your site or if you maintain a high traffic one with shareded databases and multiple fileservers :)
Thanks for your input.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最近,我发现了这个名为 Django-Backup 的解决方案,并且对我有用。您甚至可以将备份数据库或媒体文件的任务与 cronjob 结合起来。
问候,
Recently, I've found this solution called Django-Backup and has worked for me. You can even combine the task of backing up the databases or media files with a cronjob.
Regards,
我的备份解决方案按以下方式工作:
每天晚上,将数据转储到单独的目录。我更喜欢将数据转储目录与项目目录区分开来(原因之一是项目目录随着每次代码部署而变化)。
运行作业以使用
rsync
将数据上传到我的 Amazon S3 账户和另一个位置。给我发送一封包含日志的电子邮件。
为了在本地恢复备份,我使用脚本从 S3 下载数据并将其上传到本地。
My backup solution works the following way:
Every night, dump the data to a separate directory. I prefer to keep data dump directory distinct from the project directory (one reason being that project directory changes with every code deployment).
Run a job to upload the data to my Amazon S3 account and another location using
rsync
.Send me an email with the log.
To restore a backup locally I use a script to download the data from S3 and upload it locally.