Skip to content

Commit 8fbbc0d

Browse files
author
JD Bungart
committed
feat: implement tmpfs support for RouterOS backups
- Add tmpfs support for both binary and plaintext backups - Implement proper tmpfs cleanup after all operations - Update documentation with detailed tmpfs workflows - Add configuration options for tmpfs size and fallback behavior - Fix file path handling for tmpfs and root storage
1 parent 93933e2 commit 8fbbc0d

File tree

8 files changed

+708
-185
lines changed

8 files changed

+708
-185
lines changed

README.md

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,20 @@ A powerful and flexible backup solution for MikroTik RouterOS devices. This tool
1919
- Configurable retention periods
2020
- Compose-style visualization
2121
- Detailed logging
22+
- Tmpfs-based backup storage to reduce flash wear
2223

2324
- **Security Features**
2425
- SSH key-based authentication
2526
- Encrypted backups
2627
- Configurable SSH parameters
2728
- Host key verification
2829

30+
- **Storage Optimization**
31+
- Tmpfs-based temporary storage
32+
- Automatic tmpfs size calculation
33+
- Configurable fallback behavior
34+
- Flash wear reduction
35+
2936
- **Monitoring & Notifications**
3037
- Email notifications for backup status
3138
- Detailed logging with multiple levels
@@ -39,6 +46,7 @@ A powerful and flexible backup solution for MikroTik RouterOS devices. This tool
3946
- [`doc/FILESYSTEM_STRUCTURE.md`](doc/FILESYSTEM_STRUCTURE.md) - Overview of the project's directory structure and organization
4047
- [`doc/BACKUP_STRUCTURE.md`](doc/BACKUP_STRUCTURE.md) - Details about backup file formats, naming conventions, and information files
4148
- [`doc/DESIGN_REFERENCE.md`](doc/DESIGN_REFERENCE.md) - Technical documentation about application architecture and development
49+
- [`doc/TMPFS_FEATURES.md`](doc/TMPFS_FEATURES.md) - Documentation for tmpfs features
4250

4351
## Prerequisites
4452

@@ -71,31 +79,6 @@ A powerful and flexible backup solution for MikroTik RouterOS devices. This tool
7179
cp config/targets.yaml.sample config/targets.yaml
7280
```
7381

74-
5. Set up SSH keys (choose one option):
75-
76-
a. Create symbolic links to existing keys:
77-
```bash
78-
mkdir -p ssh-keys/{public,private}
79-
ln -s ~/.ssh/id_rsa ssh-keys/private/id_rosbackup
80-
ln -s ~/.ssh/id_rsa.pub ssh-keys/public/id_rosbackup.pub
81-
```
82-
83-
b. Generate new key pair:
84-
```bash
85-
mkdir -p ssh-keys/{public,private}
86-
ssh-keygen -t rsa -b 4096 -f ssh-keys/private/id_rosbackup -C "rosbackup"
87-
```
88-
89-
6. Configure RouterOS devices for backup:
90-
91-
Use `bootstrap_router.py` to bootstrap targets:
92-
```bash
93-
# Basic usage - will prompt for SSH password
94-
python3 bootstrap_router.py --host 192.168.88.1 --backup-user-public-key ssh-keys/public/id_rosbackup.pub
95-
```
96-
97-
See [BOOTSTRAP.md](BOOTSTRAP.md) for detailed usage instructions.
98-
9982
## Configuration
10083

10184
### Global Configuration (global.yaml)
@@ -127,6 +110,11 @@ ssh:
127110
auth_timeout: 10 # SSH auth timeout (optional, default: 5)
128111
#keepalive_interval: 60 # Keepalive interval (optional, default: 60)
129112
#keepalive_countmax: 3 # Max failed keepalives (optional, default: 3)
113+
114+
# Temporary Storage Settings
115+
use_tmpfs: true # Use tmpfs for temporary storage (default: true)
116+
tmpfs_fallback: true # Fall back to EEPROM if tmpfs fails (default: true)
117+
tmpfs_size: 50M # Size of tmpfs in MB (optional, auto-calculated if not set)
130118
```
131119
132120
### Target Configuration (targets.yaml)
@@ -164,6 +152,9 @@ targets:
164152
enable_plaintext_backup: true
165153
keep_binary_backup: true # Keep binary backup on router
166154
keep_plaintext_backup: true # Keep plaintext backup on router
155+
use_tmpfs: true
156+
tmpfs_fallback: true
157+
tmpfs_size: 25M # Override global tmpfs size
167158
```
168159
169160
#### Multiple Targets with Different Requirements

config/global.yaml.sample

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ ssh:
3737
#parallel_execution: true # Enable parallel backups (optional, default: true)
3838
#max_parallel_backups: 5 # Maximum concurrent backups (optional, default: 5)
3939

40+
# Temporary Storage Settings
41+
use_tmpfs: true # Use tmpfs for temporary storage (optional, default: true)
42+
#tmpfs_fallback: true # Fall back to EEPROM if tmpfs fails (optional, default: true)
43+
#tmpfs_size: 50M # Size of tmpfs in MB (optional, auto-calculated if not set)
44+
4045
# Logging Settings
4146
#log_file_enabled: false # Enable logging to file (optional, default: false)
4247
#log_file: ./rosbackup.log # Log file path (optional if log_file_enabled is false)

config/targets.yaml.sample

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ targets:
2424
#enable_plaintext_backup: true # Enable plaintext backup (optional, default: true)
2525
#keep_binary_backup: false # Keep binary backup (optional, default: false)
2626
#keep_plaintext_backup: false # Keep plaintext backup (optional, default: false)
27+
28+
# Temporary Storage Settings
29+
#use_tmpfs: true # Override global tmpfs usage (optional)
30+
#tmpfs_fallback: true # Override global tmpfs fallback (optional)
31+
#tmpfs_size: 50M # Override global tmpfs size (optional)

0 commit comments

Comments
 (0)