Docker Container Data Backup Tool
A command-line tool for backing up and restoring Docker container data.
Key Features
- Backs up and restores Docker container data volumes.
- Supports both command-line arguments and interactive operations.
- Employs XZ compression algorithm for efficient compression.
- Offers command-line completion for Bash, Zsh, Fish, and PowerShell.
- Supports custom configuration files.
Installation
Ensure you have the Rust toolchain installed on your system, then execute:
Usage
Listing Available Containers
Backing Up Container Data
Interactive Mode:
Command-line Mode:
Restoring Container Data
Interactive Mode:
Command-line Mode:
Command-Line Completion
Generate command-line completion scripts for various shells:
# Generate Bash completion script
# Generate Zsh completion script
# Generate Fish completion script
# Generate PowerShell completion script
# Windows PowerShell
Enabling Completion Functionality
Bash
Add the following lines to your ~/.bashrc or ~/.bash_profile:
Zsh
After placing the completion script in the correct location, ensure completion is enabled in your ~/.zshrc:
Fish
Fish shell automatically loads completion scripts from the ~/.config/fish/completions directory. No additional configuration is needed.
PowerShell
Add the following line to your PowerShell profile:
. $PROFILE\..\Completions\rdbkp2.ps1
Command-Line Arguments
Common Arguments
| Argument | Description | Default Value |
|---|---|---|
-y, --yes |
自动确认提示 | false |
-i, --interactive |
使用交互式模式 | true |
-v, --verbose |
显示详细日志 | false |
-t, --timeout |
容器停止超时时间(秒) | 30 |
-e, --exclude |
排除模式 | ".git,node_modules,target" |
-r, --restart |
操作后重启容器 | false |
End of Selection
Backup Command (backup)
| Argument | Description |
|---|---|
-c, --container |
Container name or ID |
-f, --file |
Path to file(s) or directory(s) to back up |
-o, --output |
Output directory |
| Inherited from common arguments | |
-i, --interactive |
Use interactive mode |
-r, --restart |
Restart the container after operation |
-t, --timeout |
Timeout for stopping the container (seconds) |
-e, --exclude |
Exclusion patterns |
Restore Command (restore)
[!CAUTION] 💖 Caution: Restoring Docker container bound volumes requires Administrator privileges. ✅ Please run [program] as
sudo/Run as Administrator.
| Argument | Description |
|---|---|
-c, --container |
Container name or ID |
-f, --file |
Path to backup file (compressed archive) |
-o, --output |
Output directory |
| Inherited from common arguments | |
-i, --interactive |
Use interactive mode |
-r, --restart |
Restart container after operation |
-t, --timeout |
Container stop timeout (seconds) |
-e, --exclude |
List Command (list)
No arguments. Displays all available containers.
Completions Command (completions)
shell: Specifies the shell type (bash/zsh/fish/powershell)
Important Notes
- When using the Restore function, ensure you operate with
sudo/ Administrator privileges.- This permission is required for write operations when changing and overwriting Docker container-mounted volumes.
- Ensure sufficient disk space is available for backups.
- It is recommended to back up your current data before restoring.
- You need to have permissions to access the Docker daemon.
- Windows users need to ensure Docker Desktop is running.