Replies: 10 comments 6 replies
-
|
Hi, did you figure out how to backup? |
Beta Was this translation helpful? Give feedback.
-
|
hi i am also looking this solution are there any guide or trick. |
Beta Was this translation helpful? Give feedback.
-
|
I did some deep dive into the structure, but I did not succeed. We just need a way to export all pages (the single page export is done via api calls) so I guess implementing this would be easy for the docmost developer. At the moment Im doing a backup of the vm, that hosts this container. |
Beta Was this translation helpful? Give feedback.
-
|
Adding to this as it's mostly related and not different enough to start a new topic. Is it possible to configure a scheduled backup/export to markdown or similar so as to have access to your documentation if your DocMost instance goes down? |
Beta Was this translation helpful? Give feedback.
-
|
Curious if there's been any headway on this? |
Beta Was this translation helpful? Give feedback.
-
|
I do not think backups belongs to the core software. I will soon be working on the backup documentation page. |
Beta Was this translation helpful? Give feedback.
-
|
backup database backup files |
Beta Was this translation helpful? Give feedback.
-
|
For what it's worth, I am now doing backups of the volumes and restore |
Beta Was this translation helpful? Give feedback.
-
|
docmost非常棒,我个人在win11上使用docmost,做了个简单的定时提醒备份,以下是我个人的实践仅供参考: 一、环境:
$ uname -a
Linux omenckk 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 24.04.1 LTS Release: 24.04 Codename: noble
D:\docmost>ls -ll
total 16
-rwxrwx---+ 1 ckk None 1738 Mar 6 10:14 docker-compose.yml
-rwxrwx---+ 1 ckk None 1763 Mar 13 11:49 export-volumes.bat
-rwxrwx---+ 1 ckk None 4016 Mar 13 11:33 import-volumes.bat
-rwxrwx---+ 1 ckk None 1661 Mar 13 12:14 notify-backup.ps1
二、备份与还原:手动导出:
添加到win定时提醒:
打开任务计划程序 按 Win + R 输入 taskschd.msc 点击确定 在右侧操作面板中点击"创建任务" 在"常规"选项卡中: 名称:输入 "Docmost存储卷备份提醒" 选择"使用最高权限运行" 配置:选择 "Windows 10" 4.在"触发器"选项卡: 点击"新建" 设置你想要的备份时间(比如每天下午5点) 5.在"操作"选项卡: 点击"新建" 程序或脚本:C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe 添加参数:-ExecutionPolicy Bypass -File "D:\docmost\notify-backup.ps1" 起始于:脚本所在的文件夹路径 6.在"条件"选项卡: 建议取消勾选"只有在计算机使用交流电源时才启动此任务" 建议取消勾选"只有在空闲时才启动此任务" 7.在"设置"选项卡: 勾选"允许按需运行任务" "如果此任务已经运行,以下规则适用"选择"请勿启动新实例" 注意事项: 确保填写 ps1 文件的完整路径 确保运行账户有足够的权限 建议先手动运行测试一下命令是否正常工作(powershell.exe -ExecutionPolicy Bypass -File "D:\docmost\notify-backup.ps1") 可以在任务计划程序的日志中查看运行记录 手动导入或恢复存储卷:
脚本文件:export-volumes.bat: @echo off
chcp 65001
setlocal enabledelayedexpansion
:: 设置导出目录
set EXPORT_DIR=E:\docker-volumes-export111
:: 设置docker镜像源
set DOCKER_MIRROR=docker.hlmirror.com/
:: 指定临时容器
set TEMP_CONTAINER=%DOCKER_MIRROR%alpine:latest
:: 创建导出目录(如果不存在)
if not exist "%EXPORT_DIR%" mkdir "%EXPORT_DIR%"
:: 列出所有卷以便确认
echo 列出所有docmost Docker卷...
docker volume ls | grep docmost
:: 下载临时容器
echo 下载临时容器...
docker pull %TEMP_CONTAINER%
:: 停止运行中的容器
echo 停止 Docker 容器...
docker-compose down
echo 导出 docmost 数据卷...
docker run --rm -v docmost_docmost:/source -v %EXPORT_DIR%:/dest %TEMP_CONTAINER% sh -c "ls -la /source && tar czf /dest/docmost_docmost.tar.gz -C /source ."
echo 导出 db_data 数据卷...
docker run --rm -v docmost_db_data:/source -v %EXPORT_DIR%:/dest %TEMP_CONTAINER% sh -c "ls -la /source && tar czf /dest/docmost_db_data.tar.gz -C /source ."
echo 导出 redis_data 数据卷...
docker run --rm -v docmost_redis_data:/source -v %EXPORT_DIR%:/dest %TEMP_CONTAINER% sh -c "ls -la /source && tar czf /dest/docmost_redis_data.tar.gz -C /source ."
:: 重新启动容器
echo 重新启动 Docker 容器...
docker-compose up -d
echo 数据卷导出完成!文件保存在: %EXPORT_DIR%
:: 自动打开导出目录
explorer "%EXPORT_DIR%"
:: 删除 pause,替换为完成通知
powershell -Command "Add-Type -AssemblyName System.Windows.Forms; $notify = New-Object System.Windows.Forms.NotifyIcon; $notify.Icon = [System.Drawing.SystemIcons]::Information; $notify.Visible = $true; $notify.ShowBalloonTip(0, '备份完成', '数据卷已成功导出到 %EXPORT_DIR%', 'Info')"notify-backup.ps1: # Create WPF window to receive notification responses
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
# Create notification icon
$notify = New-Object System.Windows.Forms.NotifyIcon
$notify.Icon = [System.Drawing.SystemIcons]::Information
$notify.Visible = $true
# Create context menu
$contextMenu = New-Object System.Windows.Forms.ContextMenuStrip
# Backup now option
$menuItemNow = New-Object System.Windows.Forms.ToolStripMenuItem
$menuItemNow.Text = "Backup Now"
$menuItemNow.Add_Click({
$notify.Dispose()
Start-Process -FilePath "D:\docmost\export-volumes.bat" -WindowStyle Hidden
$form.Close()
})
# Cancel option
$menuItemCancel = New-Object System.Windows.Forms.ToolStripMenuItem
$menuItemCancel.Text = "Cancel Backup"
$menuItemCancel.Add_Click({
$notify.Dispose()
$form.Close()
})
# Add menu items
$contextMenu.Items.Add($menuItemNow) | Out-Null
$contextMenu.Items.Add("-") | Out-Null
$contextMenu.Items.Add($menuItemCancel) | Out-Null
# Set notification icon context menu
$notify.ContextMenuStrip = $contextMenu
# Show notification
$notify.ShowBalloonTip(
0, # Display time (milliseconds)
"Backup Reminder",
"System is ready to perform data backup, please select an action",
[System.Windows.Forms.ToolTipIcon]::Info
)
# Create a hidden form to keep the script running
$form = New-Object System.Windows.Forms.Form
$form.WindowState = [System.Windows.Forms.FormWindowState]::Minimized
$form.ShowInTaskbar = $false
$form.Add_Closing({ $notify.Dispose() })
# Run application
[System.Windows.Forms.Application]::Run($form) import-volumes.bat: @echo off
chcp 65001
setlocal enabledelayedexpansion
set TOTAL_WARNINGS=10
set COUNT=1
:warning_loop
echo.
echo [%COUNT%/%TOTAL_WARNINGS%] 导入操作将会覆盖您现有的存储卷数据!请仔细确认您现在的行为!
pause
set /a COUNT+=1
if %COUNT% leq %TOTAL_WARNINGS% goto warning_loop
:: 添加初始检查
echo Starting script...
echo Checking Docker service...
docker info > nul 2>&1
if errorlevel 1 (
echo ERROR: Docker service is not running!
goto :end
)
:: 检查卷是否存在
echo Checking if volumes exist...
docker volume ls | findstr "docmost_docmost" > nul
set DOCMOST_EXISTS=%errorlevel%
docker volume ls | findstr "docmost_db_data" > nul
set DB_EXISTS=%errorlevel%
docker volume ls | findstr "docmost_redis_data" > nul
set REDIS_EXISTS=%errorlevel%
:: 如果任何一个卷不存在,则需要启动容器创建卷(保证卷是docker compose创建的!)
if %DOCMOST_EXISTS% neq 0 (
goto start_containers
) else if %DB_EXISTS% neq 0 (
goto start_containers
) else if %REDIS_EXISTS% neq 0 (
goto start_containers
) else (
echo All volumes already exist, skipping container restart.
goto continue_import
)
:start_containers
echo One or more volumes do not exist. Starting containers to create them...
echo Restarting Docker containers...
docker-compose down
docker-compose up -d
:: 等待容器启动
echo Waiting for containers to start...
docker-compose ps
:continue_import
:: 设置导入目录(与导出目录相同)
set IMPORT_DIR=E:\docker-volumes-export111
echo Import directory is: %IMPORT_DIR%
:: 设置docker镜像源
set DOCKER_MIRROR=docker.hlmirror.com/
echo Docker mirror is: %DOCKER_MIRROR%
:: 指定临时容器
set TEMP_CONTAINER=%DOCKER_MIRROR%alpine:latest
echo Temporary container is: %TEMP_CONTAINER%
:: 检查导入目录是否存在
if not exist "%IMPORT_DIR%" (
echo ERROR: Import directory %IMPORT_DIR% does not exist!
goto :end
)
echo Import directory exists.
:: 检查备份文件是否存在
if not exist "%IMPORT_DIR%\docmost_docmost.tar.gz" (
echo ERROR: docmost_docmost.tar.gz backup file does not exist!
goto :end
)
echo docmost_docmost.tar.gz backup file exists.
if not exist "%IMPORT_DIR%\docmost_db_data.tar.gz" (
echo ERROR: docmost_db_data.tar.gz backup file does not exist!
goto :end
)
echo docmost_db_data.tar.gz backup file exists.
if not exist "%IMPORT_DIR%\docmost_redis_data.tar.gz" (
echo ERROR: docmost_redis_data.tar.gz backup file does not exist!
goto :end
)
echo docmost_redis_data.tar.gz backup file exists.
:: 提示用户是否要覆盖卷
echo WARNING: One or more volumes already exist. Continuing will overwrite existing data!
choice /C YN /M "Do you want to continue"
if errorlevel 2 (
echo Operation cancelled.
goto :end
) else (
echo Proceeding with import...
)
:: 继续执行导入操作
echo Starting import process...
:: 下载临时容器
echo Downloading temporary container...
docker pull %TEMP_CONTAINER%
:: 停止运行中的容器
echo Stopping Docker containers...
docker-compose down
:: 导入 docmost 数据卷
echo Importing docmost volume...
docker run --rm -v docmost_docmost:/dest -v %IMPORT_DIR%:/source %TEMP_CONTAINER% sh -c "rm -rf /dest/* && tar xzf /source/docmost_docmost.tar.gz -C /dest"
:: 导入 db_data 数据卷
echo Importing db_data volume...
docker run --rm -v docmost_db_data:/dest -v %IMPORT_DIR%:/source %TEMP_CONTAINER% sh -c "rm -rf /dest/* && tar xzf /source/docmost_db_data.tar.gz -C /dest"
:: 导入 redis_data 数据卷
echo Importing redis_data volume...
docker run --rm -v docmost_redis_data:/dest -v %IMPORT_DIR%:/source %TEMP_CONTAINER% sh -c "rm -rf /dest/* && tar xzf /source/docmost_redis_data.tar.gz -C /dest"
:: 重新启动容器
echo Restarting Docker containers...
docker-compose up -d
echo Import completed!
:end
:: 暂停显示结果
pause |
Beta Was this translation helpful? Give feedback.
-
|
Here's my backup/restore solution with Borg. Borg takes care of file deduplication, which is an advantage over zipping the whole docker volume for each backup if you have large files attached to Docmost Prerequisites
BackupRestore |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
currently I dont know howto backup docmost so in case my server dies, I can recover and do not loose any data.
Beta Was this translation helpful? Give feedback.
All reactions