下面的代碼是用戶提交的,在使用的時候須要當心,由於 Atlassian 不提供這些代碼的技術支持。若是你在使用或者修改這些代碼的時候有任何問題,請粘貼到 post them to Atlassian Answers。mysql
刪除老的備份 —— Windows 的 Wscript 腳本
這個腳本將會檢查備份文件而後刪除他們(必要的話),下面的代碼可能須要一些編輯。web
'If you want 3 day old files to be deleted then insert 3 next to Date - "your number here" sql 'This script will search out and delete files with this string in them ".2005-12-04-" This of course depends on the number you enter. 數據庫 'You can always do a wscript.echo strYesterday or strFileName to see what the script thinks you are searching for . bash dtmYesterday = Date - 3 post strYear = Year(dtmYesterday) this strMonth = Month(dtmYesterday) spa If Len(strMonth) = 1 Then rest strMonth = "0" & strMonth code End If strDay = Day(dtmYesterday) If Len(strDay) = 1 Then strDay = "0" & strDay End If strYesterday = strYear & "-" & strMonth & "-" & strDay strFileName = "C:\test*." & strYesterday & "-*" Set objFSO = CreateObject( "Scripting.FileSystemObject" ) objFSO.DeleteFile(strFileName) |
刪除老的備份 —— Linux Basic Bash Script
Old 的 XML 備份能夠經過天天晚上或者每週的自動運行腳本進行刪除。你也能夠在 cron 中設置類似的腳本:
ls -t <path to your backup dir>/* | tail -n + 6 | xargs -i rm {} |
或者,使用 tail
命令,若是你的系統不支持標準格式的話:
ls -t <path to your backup dir>/* | tail + 6 | xargs -i rm {} |
Del 刪除老的備份 —— 高級 Linux Bash Script
Old 的 XML 備份能夠經過天天晚上或者每週的自動運行腳本進行刪除,針對你的站點設置 BACKUP_DIR 和 DAYS_TO_RETAIN 變量。在運行之間,相對 DAYS_TO_RETAIN 更多文件將會構建。
#!/bin/sh # Script to remove the older Confluence backup files. # Currently we retain at least the last two weeks worth # of backup files in order to restore if needed. BACKUP_DIR= "/data/web/confluence/backups" DAYS_TO_RETAIN= 14 find $BACKUP_DIR -maxdepth 1 -type f -ctime +$DAYS_TO_RETAIN -delete |
手動數據庫和 Home 目錄備份 —— Linux Basic Bash Script
這個將會備份 MySQL 數據庫和 Confluence 的 Home 目錄。
#!/bin/bash CNFL=/var/confluence CNFL_BACKUP=/backup/cnflBackup/`date +%Y%m%d-%H%M%S` rm -rf $CNFL/temp/* mkdir $CNFL_BACKUP mysqldump -uroot -p<password> confluence|gzip > $CNFL_BACKUP/confluence.mysql.data.gz tar -cjvf $CNFL_BACKUP/data.bzip $CNFL > $CNFL_BACKUP/homedir.status |
按照日期備份 —— Postgres
export d=`date +%u` mkdir -p /home/backup/postgres/$d sudo -u postgres pg_dumpall | bzip2 > /home/backup/postgres/$d/sql.bz2 |
https://www.cwiki.us/pages/viewpage.action?pageId=33004943