Backup and Restore
背景知識
先閱讀說明文件。
blob 備份方法 rsync specify datetime with find var/blobstorage/.layout 如果沒有備份的話,系統啟動時會重建,但重建的內含值可能錯誤,例如 lawn 而不是 bushy 會造成 POSKeyError: 'No blob file'
$ rsync -avzh marr@somesite.com:/home/marr/plone5/zinstance/var/blobstorage backup
Pack
環境變數 ZEO_PACK_KEEP_OLD 會轉變成 pack-keep-old = false 之類的設定值。
Full Backup and Incremental Backup
bin/backup 的備份方式,分成完整備份 (Full Backup) 和增量備份 (Incremental Backup) 兩種類型,第一次執行時會是完整備份,之後都是增量備份,直到系統執行數據庫擠壓 (pack) 的工作後,才會再次使用完整備份。
執行數據庫擠壓的工作,是進入 Plone 配置,點選「維護」項目。擠壓後保留的對象歷史天數,默認值是 7 天,點選「馬上擠壓數據庫」,系統開始執行數據庫的擠壓工作。
完整備份通常耗費較多時間和硬體資源,常見的方式,是在一週之類的固定時間,執行一次完整備份,其他的時段執行增量備份,以便在成本與效能之間取得最佳平衡。
$ tar --exclude='myplone/zinstance/var/blobstoragebackups' \ --exclude='hostplone/zinstance/var/backups' \ -cvpzf backup-folder/myplone-20121122.tgz myplone
Plone Backup Checklist
The complete backup for a customized Plone instance, should include:
- content
- customization
- products
- external methods
- zope configuration files
- translation files
However, the most important file is Data.fs.
Steps
先確認 Plone 系統已經停止,將 var/filestorage/Data.fs 更名為 var/filestorage/Data.fs.20110505 之類的備份檔名,執行 bin/restore 程式。
Cron Jobs
39,41c39,41 < storages=[{'backup_location': '/opt/shiji/zinstance/var/backups', < 'blob_backup_location': '/opt/shiji/zinstance/var/blobstoragebackups', < 'blob_snapshot_location': '/opt/shiji/zinstance/var/blobstoragesnapshots', --- > storages=[{'backup_location': '/opt/backup/shiji/datafs', > 'blob_backup_location': '/opt/backup/shiji/blob', > 'blob_snapshot_location': '/opt/backup/shiji/blob_shots', 44c44 < 'snapshot_location': '/opt/shiji/zinstance/var/snapshotbackups', --- > 'snapshot_location': '/opt/backup/shiji/datafs_shots',
var/blobstoragebackups 裡會建立 blobstorage.0 目錄,下次會先把 blobstorage.0 rotate 成 blobstorage.1 再建立新的 blobstorage.0 目錄,依序完整備份 blob 檔案內容,最近的目錄名稱是 blobstorage.0。在 collective.recipe.backup 設定 blob_timestamps = true 可以改用時間戳記,而不用執行 rotate。
Practice
http://pypi.python.org/pypi/munin.zope
The essential script to backup the Data.fs file is repozo
. Plone 3.x and 4.x use slightly different commands to do the real work.
Plone 3.x
$ bin/repozo -BQv -r /path/to/backup-dir -f /path/to/Plone/zinstance/var/filestorage/Data.fs
$ bin/repozo -R -r /path/to/backup-dir -o myData.fs
Plone 4.0.x
Run bin/backup
and it will call the repozo
script. If there is no bin/repozo
, the easiest way is to add a new section in the buildout.cfg
:
parts =
...
repozo
[repozo]
recipe = zc.recipe.egg
eggs = ZODB3
scripts = repozo
In case no show in bin folder, dependent-scripts = true
might be needed.
Plone 4.1.x Later
Simply run bin/backup that should work with bin/repozo by default.
INFO: Please wait while backing up database file: /home/marr/plone/zinstance/var/filestorage/Data.fs to /home/marr/backup/plone_datafs INFO: Please wait while backing up blobs from /home/marr/plone/zinstance/var/blobstorage to /home/marr/backup/plone_blob INFO: Renaming blobstorage.4 to blobstorage.5. INFO: Renaming blobstorage.3 to blobstorage.4. INFO: Renaming blobstorage.2 to blobstorage.3. INFO: Renaming blobstorage.1 to blobstorage.2. INFO: Renaming blobstorage.0 to blobstorage.1. INFO: rsync -a --delete --link-dest=../blobstorage.1 /home/marr/plone/zinstance/var/blobstorage /home/marr/backup/plone_blob/blobstorage.0 INFO: Removed 1 blob backup(s), the latest 14 day(s) of backups have been kept.
ZODB Blob 個別設定
In Plone, if you have problems with blobs and you view a message like this: “No blob file”.
Sometimes is good to know, which file is “not found”… (normally the path where you copied the file is not correct) :)
If you edit the file:
(In the frontend)
vi ./eggs/ZODB3-3.10.3-py2.6-linux-x86_64.egg/ZEO/ClientStorage.py line 1020 is:
raise POSException.POSKeyError(“No blob file”, oid, serial)
And put this line before:
raise POSException.Unsupported(“Blob not found”, blob_filename)
Then if you start the instance in foreground, you can see the name file and the path in the log.
http://www.abstract.it/it/blog/bisco/shared-hosting-zodb-e-blobstorage-separati
讓每個 Plone instance 有獨立的 Data.fs 和 BlobStorage,會帶來備份時的彈性,但設定上也變得更複雜。
http://pypi.python.org/pypi/collective.recipe.filestorage
參數設定包括:
- zodb-mountpoint indicates the location of the various bodies
- blob-storage is the path to save the blob to the filesystem
- parts is the list of instances to be configured
- % (Fs_part_name) s is automatically replaced with the contents of the variable parts
Reference
- Pack ZODB from Command Line
- Correct way to backup ZODB blobs
- Backup Plone by Rene Pijlman and more documents from Plone.org
- rsnapshot
- Cron Job with Basic HTTP Authentication
- ZODB Bloat by Large Objects
- Plone/ZeoCluster Performance Problems
- Choosing Filesystem for ZODB
Note
Simply tar ball of Plone might not work in different Linux.
$ file /home/marr/Plone/Python-2.4/bin/python /home/marr/Plone/Python-2.4/bin/python: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
ZEO server and updateRoleMappings() need checking.
Log Rotation
http://stackoverflow.com/questions/9426545
INFO: Please wait while backing up database file: /opt/plone/zinstance/var/filestorage/Data.fs to /nfs/backup/plone_datafs INFO: Please wait while backing up blobs from /opt/plone/zinstance/var/blobstorage to /opt2/backup/plone_blob INFO: Renaming blobstorage.12 to blobstorage.13. INFO: Renaming blobstorage.11 to blobstorage.12. INFO: Renaming blobstorage.10 to blobstorage.11. INFO: Renaming blobstorage.9 to blobstorage.10. INFO: Renaming blobstorage.8 to blobstorage.9. INFO: Renaming blobstorage.7 to blobstorage.8. INFO: Renaming blobstorage.6 to blobstorage.7. INFO: Renaming blobstorage.5 to blobstorage.6. INFO: Renaming blobstorage.4 to blobstorage.5. INFO: Renaming blobstorage.3 to blobstorage.4. INFO: Renaming blobstorage.2 to blobstorage.3. INFO: Renaming blobstorage.1 to blobstorage.2. INFO: Renaming blobstorage.0 to blobstorage.1. INFO: rsync -a --delete --link-dest=../blobstorage.1 /opt/plone/zinstance/var/blobstorage /opt2/backup/plone_blob/blobstorage.0
Static HTML
2015 discussion: stxnext.staticdeployment httrack wget locally browsable wget_plone.sh grad-site ca_mirror Ruby: Plone to HTML