Confluence 6 用户提交的备份和恢复脚本
下面的代码是用户提交的,在使用的时候需要小心,因为 Atlassian 不提供这些代码的技术支持。如果你在使用或者修改这些代码的时候有任何问题,请粘贴到 post them to Atlassian Answers。
删除老的备份 —— Windows 的 Wscript 脚本
这个脚本将会检查备份文件然后删除他们(必要的话),下面的代码可能需要一些编辑。
'If you want 3 day old files to be deleted then insert 3 next to Date - "your number here" '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 . dtmYesterday = Date - 3 strYear = Year(dtmYesterday) strMonth = Month(dtmYesterday) If Len(strMonth) = 1 Then strMonth = "0" & strMonth 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 |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?