@intentsolutionsio/fairdb-operations-kit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +26 -0
- package/LICENSE +21 -0
- package/README.md +298 -0
- package/agents/fairdb-automation-agent.md +307 -0
- package/commands/fairdb-emergency-response.md +480 -0
- package/commands/fairdb-health-check.md +459 -0
- package/commands/fairdb-onboard-customer.md +446 -0
- package/commands/fairdb-setup-backup.md +420 -0
- package/package.json +48 -0
- package/skills/fairdb-backup-manager/SKILL.md +72 -0
- package/skills/fairdb-backup-manager/assets/README.md +26 -0
- package/skills/fairdb-backup-manager/references/README.md +26 -0
- package/skills/fairdb-backup-manager/scripts/README.md +24 -0
- package/skills/skill-adapter/assets/README.md +4 -0
- package/skills/skill-adapter/assets/config-template.json +32 -0
- package/skills/skill-adapter/assets/skill-schema.json +28 -0
- package/skills/skill-adapter/assets/test-data.json +27 -0
- package/skills/skill-adapter/references/README.md +4 -0
- package/skills/skill-adapter/references/best-practices.md +69 -0
- package/skills/skill-adapter/references/examples.md +73 -0
- package/skills/skill-adapter/scripts/README.md +10 -0
- package/skills/skill-adapter/scripts/helper-template.sh +42 -0
- package/skills/skill-adapter/scripts/validation.sh +32 -0
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fairdb-setup-backup
|
|
3
|
+
description: Configure pgBackRest with Wasabi S3 for automated PostgreSQL backups
|
|
4
|
+
model: sonnet
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# FairDB pgBackRest Backup Configuration with Wasabi S3
|
|
8
|
+
|
|
9
|
+
You are configuring pgBackRest with Wasabi S3 storage for automated PostgreSQL backups. Follow SOP-003 precisely.
|
|
10
|
+
|
|
11
|
+
## Prerequisites Check
|
|
12
|
+
|
|
13
|
+
Verify before starting:
|
|
14
|
+
1. PostgreSQL 16 is installed and running
|
|
15
|
+
2. Wasabi S3 account is active with bucket created
|
|
16
|
+
3. AWS CLI credentials are available
|
|
17
|
+
4. At least 50GB free disk space for local backups
|
|
18
|
+
|
|
19
|
+
## Step 1: Install pgBackRest
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Add pgBackRest repository
|
|
23
|
+
sudo apt-get install -y software-properties-common
|
|
24
|
+
sudo add-apt-repository -y ppa:pgbackrest/backrest
|
|
25
|
+
sudo apt-get update
|
|
26
|
+
|
|
27
|
+
# Install pgBackRest
|
|
28
|
+
sudo apt-get install -y pgbackrest
|
|
29
|
+
|
|
30
|
+
# Verify installation
|
|
31
|
+
pgbackrest version
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Step 2: Configure Wasabi S3 Credentials
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Create pgBackRest configuration directory
|
|
38
|
+
sudo mkdir -p /etc/pgbackrest
|
|
39
|
+
sudo mkdir -p /var/lib/pgbackrest
|
|
40
|
+
sudo mkdir -p /var/log/pgbackrest
|
|
41
|
+
sudo mkdir -p /var/spool/pgbackrest
|
|
42
|
+
|
|
43
|
+
# Set ownership
|
|
44
|
+
sudo chown -R postgres:postgres /var/lib/pgbackrest
|
|
45
|
+
sudo chown -R postgres:postgres /var/log/pgbackrest
|
|
46
|
+
sudo chown -R postgres:postgres /var/spool/pgbackrest
|
|
47
|
+
|
|
48
|
+
# Store Wasabi credentials (secure these!)
|
|
49
|
+
export WASABI_ACCESS_KEY="YOUR_WASABI_ACCESS_KEY"
|
|
50
|
+
export WASABI_SECRET_KEY="YOUR_WASABI_SECRET_KEY"
|
|
51
|
+
export WASABI_BUCKET="fairdb-backups"
|
|
52
|
+
export WASABI_REGION="us-east-1" # Or your Wasabi region
|
|
53
|
+
export WASABI_ENDPOINT="s3.us-east-1.wasabisys.com" # Adjust for your region
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Step 3: Create pgBackRest Configuration
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Create main configuration file
|
|
60
|
+
sudo tee /etc/pgbackrest/pgbackrest.conf << EOF
|
|
61
|
+
[global]
|
|
62
|
+
# General Options
|
|
63
|
+
process-max=4
|
|
64
|
+
log-level-console=info
|
|
65
|
+
log-level-file=detail
|
|
66
|
+
start-fast=y
|
|
67
|
+
stop-auto=y
|
|
68
|
+
archive-async=y
|
|
69
|
+
archive-push-queue-max=4GB
|
|
70
|
+
spool-path=/var/spool/pgbackrest
|
|
71
|
+
|
|
72
|
+
# S3 Repository Configuration
|
|
73
|
+
repo1-type=s3
|
|
74
|
+
repo1-s3-endpoint=${WASABI_ENDPOINT}
|
|
75
|
+
repo1-s3-bucket=${WASABI_BUCKET}
|
|
76
|
+
repo1-s3-region=${WASABI_REGION}
|
|
77
|
+
repo1-s3-key=${WASABI_ACCESS_KEY}
|
|
78
|
+
repo1-s3-key-secret=${WASABI_SECRET_KEY}
|
|
79
|
+
repo1-path=/pgbackrest
|
|
80
|
+
repo1-retention-full=4
|
|
81
|
+
repo1-retention-diff=12
|
|
82
|
+
repo1-retention-archive=30
|
|
83
|
+
repo1-cipher-type=aes-256-cbc
|
|
84
|
+
repo1-cipher-pass=CHANGE_THIS_PASSPHRASE
|
|
85
|
+
|
|
86
|
+
# Local Repository (for faster restores)
|
|
87
|
+
repo2-type=posix
|
|
88
|
+
repo2-path=/var/lib/pgbackrest
|
|
89
|
+
repo2-retention-full=2
|
|
90
|
+
repo2-retention-diff=6
|
|
91
|
+
|
|
92
|
+
[fairdb]
|
|
93
|
+
# PostgreSQL Configuration
|
|
94
|
+
pg1-path=/var/lib/postgresql/16/main
|
|
95
|
+
pg1-port=5432
|
|
96
|
+
pg1-user=postgres
|
|
97
|
+
|
|
98
|
+
# Archive Configuration
|
|
99
|
+
archive-timeout=60
|
|
100
|
+
archive-check=y
|
|
101
|
+
backup-standby=n
|
|
102
|
+
|
|
103
|
+
# Backup Options
|
|
104
|
+
compress-type=lz4
|
|
105
|
+
compress-level=3
|
|
106
|
+
backup-user=backup_user
|
|
107
|
+
delta=y
|
|
108
|
+
process-max=2
|
|
109
|
+
EOF
|
|
110
|
+
|
|
111
|
+
# Secure the configuration file
|
|
112
|
+
sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
|
|
113
|
+
sudo chown postgres:postgres /etc/pgbackrest/pgbackrest.conf
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Step 4: Configure PostgreSQL for pgBackRest
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Update PostgreSQL configuration
|
|
120
|
+
sudo tee -a /etc/postgresql/16/main/postgresql.conf << 'EOF'
|
|
121
|
+
|
|
122
|
+
# pgBackRest Archive Configuration
|
|
123
|
+
archive_mode = on
|
|
124
|
+
archive_command = 'pgbackrest --stanza=fairdb archive-push %p'
|
|
125
|
+
archive_timeout = 60
|
|
126
|
+
max_wal_senders = 3
|
|
127
|
+
wal_level = replica
|
|
128
|
+
wal_log_hints = on
|
|
129
|
+
EOF
|
|
130
|
+
|
|
131
|
+
# Restart PostgreSQL
|
|
132
|
+
sudo systemctl restart postgresql
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Step 5: Initialize Backup Stanza
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Create the stanza
|
|
139
|
+
sudo -u postgres pgbackrest --stanza=fairdb stanza-create
|
|
140
|
+
|
|
141
|
+
# Verify stanza
|
|
142
|
+
sudo -u postgres pgbackrest --stanza=fairdb check
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Step 6: Create Backup Scripts
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Full backup script
|
|
149
|
+
sudo tee /opt/fairdb/scripts/backup-full.sh << 'EOF'
|
|
150
|
+
#!/bin/bash
|
|
151
|
+
set -e
|
|
152
|
+
|
|
153
|
+
LOG_FILE="/var/log/fairdb/backup-full-$(date +%Y%m%d-%H%M%S).log"
|
|
154
|
+
echo "Starting full backup at $(date)" | tee -a $LOG_FILE
|
|
155
|
+
|
|
156
|
+
# Perform full backup to both repositories
|
|
157
|
+
sudo -u postgres pgbackrest --stanza=fairdb --type=full --repo=1 backup 2>&1 | tee -a $LOG_FILE
|
|
158
|
+
sudo -u postgres pgbackrest --stanza=fairdb --type=full --repo=2 backup 2>&1 | tee -a $LOG_FILE
|
|
159
|
+
|
|
160
|
+
# Verify backup
|
|
161
|
+
sudo -u postgres pgbackrest --stanza=fairdb --repo=1 info 2>&1 | tee -a $LOG_FILE
|
|
162
|
+
|
|
163
|
+
echo "Full backup completed at $(date)" | tee -a $LOG_FILE
|
|
164
|
+
|
|
165
|
+
# Send notification (implement webhook/email here)
|
|
166
|
+
curl -X POST $FAIRDB_MONITORING_WEBHOOK \
|
|
167
|
+
-H 'Content-Type: application/json' \
|
|
168
|
+
-d "{\"text\":\"FairDB full backup completed successfully\"}" 2>/dev/null || true
|
|
169
|
+
EOF
|
|
170
|
+
|
|
171
|
+
# Incremental backup script
|
|
172
|
+
sudo tee /opt/fairdb/scripts/backup-incremental.sh << 'EOF'
|
|
173
|
+
#!/bin/bash
|
|
174
|
+
set -e
|
|
175
|
+
|
|
176
|
+
LOG_FILE="/var/log/fairdb/backup-incr-$(date +%Y%m%d-%H%M%S).log"
|
|
177
|
+
echo "Starting incremental backup at $(date)" | tee -a $LOG_FILE
|
|
178
|
+
|
|
179
|
+
# Perform incremental backup
|
|
180
|
+
sudo -u postgres pgbackrest --stanza=fairdb --type=incr --repo=1 backup 2>&1 | tee -a $LOG_FILE
|
|
181
|
+
|
|
182
|
+
echo "Incremental backup completed at $(date)" | tee -a $LOG_FILE
|
|
183
|
+
EOF
|
|
184
|
+
|
|
185
|
+
# Differential backup script
|
|
186
|
+
sudo tee /opt/fairdb/scripts/backup-differential.sh << 'EOF'
|
|
187
|
+
#!/bin/bash
|
|
188
|
+
set -e
|
|
189
|
+
|
|
190
|
+
LOG_FILE="/var/log/fairdb/backup-diff-$(date +%Y%m%d-%H%M%S).log"
|
|
191
|
+
echo "Starting differential backup at $(date)" | tee -a $LOG_FILE
|
|
192
|
+
|
|
193
|
+
# Perform differential backup
|
|
194
|
+
sudo -u postgres pgbackrest --stanza=fairdb --type=diff --repo=1 backup 2>&1 | tee -a $LOG_FILE
|
|
195
|
+
|
|
196
|
+
echo "Differential backup completed at $(date)" | tee -a $LOG_FILE
|
|
197
|
+
EOF
|
|
198
|
+
|
|
199
|
+
# Make scripts executable
|
|
200
|
+
sudo chmod +x /opt/fairdb/scripts/backup-*.sh
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Step 7: Schedule Automated Backups
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
# Add to root's crontab for automated backups
|
|
207
|
+
cat << 'EOF' | sudo tee /etc/cron.d/fairdb-backups
|
|
208
|
+
# FairDB Automated Backup Schedule
|
|
209
|
+
SHELL=/bin/bash
|
|
210
|
+
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
|
211
|
+
|
|
212
|
+
# Weekly full backup (Sunday 2 AM)
|
|
213
|
+
0 2 * * 0 root /opt/fairdb/scripts/backup-full.sh
|
|
214
|
+
|
|
215
|
+
# Daily differential backup (Mon-Sat 2 AM)
|
|
216
|
+
0 2 * * 1-6 root /opt/fairdb/scripts/backup-differential.sh
|
|
217
|
+
|
|
218
|
+
# Hourly incremental backup (business hours)
|
|
219
|
+
0 9-18 * * 1-5 root /opt/fairdb/scripts/backup-incremental.sh
|
|
220
|
+
|
|
221
|
+
# Backup verification (daily at 5 AM)
|
|
222
|
+
0 5 * * * postgres pgbackrest --stanza=fairdb --repo=1 check
|
|
223
|
+
|
|
224
|
+
# Archive expiration (daily at 3 AM)
|
|
225
|
+
0 3 * * * postgres pgbackrest --stanza=fairdb --repo=1 expire
|
|
226
|
+
EOF
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Step 8: Create Restore Procedures
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
# Point-in-time recovery script
|
|
233
|
+
sudo tee /opt/fairdb/scripts/restore-pitr.sh << 'EOF'
|
|
234
|
+
#!/bin/bash
|
|
235
|
+
# FairDB Point-in-Time Recovery Script
|
|
236
|
+
|
|
237
|
+
if [ $# -ne 1 ]; then
|
|
238
|
+
echo "Usage: $0 'YYYY-MM-DD HH:MM:SS'"
|
|
239
|
+
exit 1
|
|
240
|
+
fi
|
|
241
|
+
|
|
242
|
+
TARGET_TIME="$1"
|
|
243
|
+
BACKUP_PATH="/var/lib/postgresql/16/main"
|
|
244
|
+
|
|
245
|
+
echo "WARNING: This will restore the database to $TARGET_TIME"
|
|
246
|
+
echo "Current data will be LOST. Continue? (yes/no)"
|
|
247
|
+
read CONFIRM
|
|
248
|
+
|
|
249
|
+
if [ "$CONFIRM" != "yes" ]; then
|
|
250
|
+
echo "Restore cancelled"
|
|
251
|
+
exit 1
|
|
252
|
+
fi
|
|
253
|
+
|
|
254
|
+
# Stop PostgreSQL
|
|
255
|
+
sudo systemctl stop postgresql
|
|
256
|
+
|
|
257
|
+
# Clear data directory
|
|
258
|
+
sudo rm -rf ${BACKUP_PATH}/*
|
|
259
|
+
|
|
260
|
+
# Restore to target time
|
|
261
|
+
sudo -u postgres pgbackrest --stanza=fairdb \
|
|
262
|
+
--type=time \
|
|
263
|
+
--target="$TARGET_TIME" \
|
|
264
|
+
--target-action=promote \
|
|
265
|
+
restore
|
|
266
|
+
|
|
267
|
+
# Start PostgreSQL
|
|
268
|
+
sudo systemctl start postgresql
|
|
269
|
+
|
|
270
|
+
echo "Restore completed. Verify data integrity."
|
|
271
|
+
EOF
|
|
272
|
+
|
|
273
|
+
sudo chmod +x /opt/fairdb/scripts/restore-pitr.sh
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## Step 9: Test Backup and Restore
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
# Perform test backup
|
|
280
|
+
sudo -u postgres pgbackrest --stanza=fairdb --type=full backup
|
|
281
|
+
|
|
282
|
+
# Check backup info
|
|
283
|
+
sudo -u postgres pgbackrest --stanza=fairdb info
|
|
284
|
+
|
|
285
|
+
# List backups
|
|
286
|
+
sudo -u postgres pgbackrest --stanza=fairdb info --output=json
|
|
287
|
+
|
|
288
|
+
# Test restore to alternate location
|
|
289
|
+
sudo mkdir -p /tmp/pgbackrest-test
|
|
290
|
+
sudo chown postgres:postgres /tmp/pgbackrest-test
|
|
291
|
+
sudo -u postgres pgbackrest --stanza=fairdb \
|
|
292
|
+
--pg1-path=/tmp/pgbackrest-test \
|
|
293
|
+
--type=latest \
|
|
294
|
+
restore
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## Step 10: Monitor Backup Health
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# Create monitoring script
|
|
301
|
+
sudo tee /opt/fairdb/scripts/check-backup-health.sh << 'EOF'
|
|
302
|
+
#!/bin/bash
|
|
303
|
+
# FairDB Backup Health Check
|
|
304
|
+
|
|
305
|
+
# Check last backup time
|
|
306
|
+
LAST_BACKUP=$(sudo -u postgres pgbackrest --stanza=fairdb info --output=json | \
|
|
307
|
+
jq -r '.[] | .backup[-1].timestamp.stop')
|
|
308
|
+
|
|
309
|
+
# Convert to seconds
|
|
310
|
+
LAST_BACKUP_EPOCH=$(date -d "$LAST_BACKUP" +%s)
|
|
311
|
+
CURRENT_EPOCH=$(date +%s)
|
|
312
|
+
HOURS_AGO=$(( ($CURRENT_EPOCH - $LAST_BACKUP_EPOCH) / 3600 ))
|
|
313
|
+
|
|
314
|
+
# Alert if backup is older than 25 hours
|
|
315
|
+
if [ $HOURS_AGO -gt 25 ]; then
|
|
316
|
+
echo "ALERT: Last backup was $HOURS_AGO hours ago!"
|
|
317
|
+
# Send alert (implement notification here)
|
|
318
|
+
exit 1
|
|
319
|
+
fi
|
|
320
|
+
|
|
321
|
+
echo "Backup health OK - last backup $HOURS_AGO hours ago"
|
|
322
|
+
|
|
323
|
+
# Check S3 connectivity
|
|
324
|
+
aws s3 ls s3://${WASABI_BUCKET}/pgbackrest/ \
|
|
325
|
+
--endpoint-url=https://${WASABI_ENDPOINT} > /dev/null 2>&1
|
|
326
|
+
if [ $? -ne 0 ]; then
|
|
327
|
+
echo "ALERT: Cannot connect to Wasabi S3!"
|
|
328
|
+
exit 1
|
|
329
|
+
fi
|
|
330
|
+
|
|
331
|
+
echo "S3 connectivity OK"
|
|
332
|
+
EOF
|
|
333
|
+
|
|
334
|
+
sudo chmod +x /opt/fairdb/scripts/check-backup-health.sh
|
|
335
|
+
|
|
336
|
+
# Add to monitoring cron
|
|
337
|
+
echo "*/30 * * * * root /opt/fairdb/scripts/check-backup-health.sh" | \
|
|
338
|
+
sudo tee -a /etc/cron.d/fairdb-monitoring
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## Step 11: Document Backup Configuration
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
cat > /opt/fairdb/configs/backup-info.txt << EOF
|
|
345
|
+
FairDB Backup Configuration
|
|
346
|
+
===========================
|
|
347
|
+
Backup Solution: pgBackRest
|
|
348
|
+
Primary Repository: Wasabi S3 (${WASABI_BUCKET})
|
|
349
|
+
Secondary Repository: Local (/var/lib/pgbackrest)
|
|
350
|
+
Stanza Name: fairdb
|
|
351
|
+
Encryption: AES-256-CBC
|
|
352
|
+
|
|
353
|
+
Retention Policy:
|
|
354
|
+
- Full Backups: 4 (S3), 2 (Local)
|
|
355
|
+
- Differential: 12 (S3), 6 (Local)
|
|
356
|
+
- WAL Archives: 30 days
|
|
357
|
+
|
|
358
|
+
Schedule:
|
|
359
|
+
- Full: Weekly (Sunday 2 AM)
|
|
360
|
+
- Differential: Daily (Mon-Sat 2 AM)
|
|
361
|
+
- Incremental: Hourly (9 AM - 6 PM weekdays)
|
|
362
|
+
|
|
363
|
+
Restore Procedures:
|
|
364
|
+
- Latest: pgbackrest --stanza=fairdb restore
|
|
365
|
+
- PITR: /opt/fairdb/scripts/restore-pitr.sh 'YYYY-MM-DD HH:MM:SS'
|
|
366
|
+
|
|
367
|
+
Monitoring:
|
|
368
|
+
- Health checks: Every 30 minutes
|
|
369
|
+
- Verification: Daily at 5 AM
|
|
370
|
+
- Expiration: Daily at 3 AM
|
|
371
|
+
EOF
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
## Verification Checklist
|
|
375
|
+
|
|
376
|
+
Confirm these items:
|
|
377
|
+
- [ ] pgBackRest installed and configured
|
|
378
|
+
- [ ] Wasabi S3 credentials configured
|
|
379
|
+
- [ ] Stanza created and verified
|
|
380
|
+
- [ ] PostgreSQL archive_command configured
|
|
381
|
+
- [ ] Backup scripts created and executable
|
|
382
|
+
- [ ] Automated schedule configured
|
|
383
|
+
- [ ] Test backup successful
|
|
384
|
+
- [ ] Test restore successful
|
|
385
|
+
- [ ] Monitoring scripts in place
|
|
386
|
+
- [ ] Documentation complete
|
|
387
|
+
|
|
388
|
+
## Security Notes
|
|
389
|
+
|
|
390
|
+
- Store Wasabi credentials securely (use AWS Secrets Manager in production)
|
|
391
|
+
- Encrypt backup repository with strong passphrase
|
|
392
|
+
- Regularly test restore procedures
|
|
393
|
+
- Monitor backup logs for failures
|
|
394
|
+
- Keep pgBackRest updated
|
|
395
|
+
|
|
396
|
+
## Output Summary
|
|
397
|
+
|
|
398
|
+
Provide the user with:
|
|
399
|
+
1. Backup stanza status: `pgbackrest --stanza=fairdb info`
|
|
400
|
+
2. Next full backup time from cron schedule
|
|
401
|
+
3. Location of backup scripts and logs
|
|
402
|
+
4. Restore procedure documentation
|
|
403
|
+
5. Monitoring webhook configuration needed
|
|
404
|
+
|
|
405
|
+
## Important Commands
|
|
406
|
+
|
|
407
|
+
```bash
|
|
408
|
+
# Manual backup commands
|
|
409
|
+
sudo -u postgres pgbackrest --stanza=fairdb --type=full backup # Full
|
|
410
|
+
sudo -u postgres pgbackrest --stanza=fairdb --type=diff backup # Differential
|
|
411
|
+
sudo -u postgres pgbackrest --stanza=fairdb --type=incr backup # Incremental
|
|
412
|
+
|
|
413
|
+
# Check backup status
|
|
414
|
+
sudo -u postgres pgbackrest --stanza=fairdb info
|
|
415
|
+
sudo -u postgres pgbackrest --stanza=fairdb check
|
|
416
|
+
|
|
417
|
+
# Restore commands
|
|
418
|
+
sudo -u postgres pgbackrest --stanza=fairdb restore # Latest
|
|
419
|
+
sudo -u postgres pgbackrest --stanza=fairdb --type=time --target="2024-01-01 12:00:00" restore # PITR
|
|
420
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@intentsolutionsio/fairdb-operations-kit",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Complete operations kit for FairDB PostgreSQL as a Service - VPS setup, PostgreSQL management, customer provisioning, monitoring, and backup automation",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"fairdb",
|
|
7
|
+
"postgresql",
|
|
8
|
+
"database",
|
|
9
|
+
"saas",
|
|
10
|
+
"operations",
|
|
11
|
+
"devops",
|
|
12
|
+
"backup",
|
|
13
|
+
"monitoring",
|
|
14
|
+
"vps",
|
|
15
|
+
"contabo",
|
|
16
|
+
"wasabi",
|
|
17
|
+
"pgbackrest",
|
|
18
|
+
"automation",
|
|
19
|
+
"claude-code",
|
|
20
|
+
"claude-plugin",
|
|
21
|
+
"tonsofskills"
|
|
22
|
+
],
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/jeremylongshore/claude-code-plugins-plus-skills.git",
|
|
26
|
+
"directory": "plugins/devops/fairdb-operations-kit"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://tonsofskills.com/plugins/fairdb-operations-kit",
|
|
29
|
+
"bugs": "https://github.com/jeremylongshore/claude-code-plugins-plus-skills/issues",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"author": {
|
|
32
|
+
"name": "Jeremy Longshore",
|
|
33
|
+
"email": "jeremy@intentsolutions.io"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"README.md",
|
|
40
|
+
".claude-plugin",
|
|
41
|
+
"skills",
|
|
42
|
+
"commands",
|
|
43
|
+
"agents"
|
|
44
|
+
],
|
|
45
|
+
"scripts": {
|
|
46
|
+
"postinstall": "node -e \"console.log(\\\"\\\\n→ This npm package is a tracking/proof artifact. Install the plugin via:\\\\n ccpi install fairdb-operations-kit\\\\n or /plugin install fairdb-operations-kit@claude-code-plugins-plus in Claude Code\\\\n\\\")\""
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fairdb-backup-manager
|
|
3
|
+
description: |
|
|
4
|
+
Manage use when you need to work with backup and recovery.
|
|
5
|
+
This skill provides backup automation and disaster recovery with comprehensive guidance and automation.
|
|
6
|
+
Trigger with phrases like "create backups", "automate backups",
|
|
7
|
+
or "implement disaster recovery".
|
|
8
|
+
|
|
9
|
+
allowed-tools: Read, Write, Edit, Grep, Glob, Bash(tar:*), Bash(rsync:*), Bash(aws:s3:*)
|
|
10
|
+
version: 1.0.0
|
|
11
|
+
author: Jeremy Longshore <jeremy@intentsolutions.io>
|
|
12
|
+
license: MIT
|
|
13
|
+
compatible-with: claude-code, codex, openclaw
|
|
14
|
+
tags: [devops, backup, disaster-recovery]
|
|
15
|
+
---
|
|
16
|
+
# FairDB Backup Manager
|
|
17
|
+
|
|
18
|
+
## Overview
|
|
19
|
+
|
|
20
|
+
Automate backup and recovery operations for FairDB database instances. Generate backup scripts, configure retention policies, schedule automated backups to local storage or S3, and produce tested restore procedures with integrity verification.
|
|
21
|
+
|
|
22
|
+
## Prerequisites
|
|
23
|
+
|
|
24
|
+
- FairDB instance running and accessible with admin credentials
|
|
25
|
+
- `tar` and `rsync` installed for file-level backups
|
|
26
|
+
- AWS CLI configured with `s3:PutObject` and `s3:GetObject` permissions (if using S3 as backup target)
|
|
27
|
+
- Sufficient storage at backup destination (2-3x database size for rotation)
|
|
28
|
+
- Cron or systemd timer access for scheduling
|
|
29
|
+
- Test environment available for restore verification
|
|
30
|
+
|
|
31
|
+
## Instructions
|
|
32
|
+
|
|
33
|
+
1. Assess the FairDB instance: identify data directory location, database size, and write throughput
|
|
34
|
+
2. Select backup method: logical dump for portability, filesystem snapshot for speed, or continuous archiving for minimal RPO
|
|
35
|
+
3. Generate backup script with lock acquisition, data export, compression (`tar czf`), and checksum generation
|
|
36
|
+
4. Configure S3 upload with server-side encryption (`aws s3 cp --sse aws:kms`) for off-site copies
|
|
37
|
+
5. Set up retention policy: keep hourly backups for 24 hours, daily for 7 days, weekly for 4 weeks, monthly for 12 months
|
|
38
|
+
6. Create cleanup script to purge expired backups according to retention schedule
|
|
39
|
+
7. Schedule backups via cron with proper logging to `/var/log/fairdb-backup.log`
|
|
40
|
+
8. Generate restore procedure: download from S3, verify checksum, decompress, and import with validation query
|
|
41
|
+
9. Test restore procedure in a staging environment and document the time-to-recovery
|
|
42
|
+
|
|
43
|
+
## Output
|
|
44
|
+
|
|
45
|
+
- Backup shell script with logging, locking, compression, and S3 upload
|
|
46
|
+
- Restore shell script with checksum verification and data validation
|
|
47
|
+
- Cron schedule entries or systemd timer units
|
|
48
|
+
- Retention cleanup script
|
|
49
|
+
- S3 lifecycle policy configuration for long-term archive tiering
|
|
50
|
+
|
|
51
|
+
## Error Handling
|
|
52
|
+
|
|
53
|
+
| Error | Cause | Solution |
|
|
54
|
+
|-------|-------|---------|
|
|
55
|
+
| `Backup lock acquisition failed` | Another backup or maintenance process is running | Check for stale lock files; implement timeout-based lock with `flock` |
|
|
56
|
+
| `tar: Cannot open: No space left on device` | Local backup destination full | Run retention cleanup; check disk usage with `df -h`; increase volume size |
|
|
57
|
+
| `aws s3 cp: upload failed` | Network issue or expired AWS credentials | Retry with `--retry 3`; refresh credentials; check S3 bucket permissions |
|
|
58
|
+
| `Restore failed: checksum mismatch` | Backup file corrupted during transfer or storage | Re-download from S3; verify S3 object integrity; use a different backup copy |
|
|
59
|
+
| `Database inconsistent after restore` | Backup taken during active write without lock | Ensure backup script acquires a consistent snapshot lock before export |
|
|
60
|
+
|
|
61
|
+
## Examples
|
|
62
|
+
|
|
63
|
+
- "Create an automated nightly backup for the FairDB production instance, compressed and uploaded to S3 with KMS encryption and 30-day retention."
|
|
64
|
+
- "Generate a restore runbook that pulls the latest backup from S3, verifies integrity, and restores to a staging instance for validation."
|
|
65
|
+
- "Set up backup monitoring that alerts via Slack if a backup job fails or if no successful backup exists within the last 25 hours."
|
|
66
|
+
|
|
67
|
+
## Resources
|
|
68
|
+
|
|
69
|
+
- AWS S3 CLI: https://docs.aws.amazon.com/cli/latest/reference/s3/
|
|
70
|
+
- rsync documentation: https://rsync.samba.org/documentation.html
|
|
71
|
+
- Backup automation patterns: https://www.veeam.com/blog/321-backup-rule.html
|
|
72
|
+
- Linux cron scheduling: https://crontab.guru/
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Skill Assets
|
|
2
|
+
|
|
3
|
+
This directory contains static assets used by this skill.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
Assets can include:
|
|
8
|
+
- Configuration files (JSON, YAML)
|
|
9
|
+
- Data files
|
|
10
|
+
- Templates
|
|
11
|
+
- Schemas
|
|
12
|
+
- Test fixtures
|
|
13
|
+
|
|
14
|
+
## Guidelines
|
|
15
|
+
|
|
16
|
+
- Keep assets small and focused
|
|
17
|
+
- Document asset purpose and format
|
|
18
|
+
- Use standard file formats
|
|
19
|
+
- Include schema validation where applicable
|
|
20
|
+
|
|
21
|
+
## Common Asset Types
|
|
22
|
+
|
|
23
|
+
- **config.json** - Configuration templates
|
|
24
|
+
- **schema.json** - JSON schemas
|
|
25
|
+
- **template.yaml** - YAML templates
|
|
26
|
+
- **test-data.json** - Test fixtures
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Skill References
|
|
2
|
+
|
|
3
|
+
This directory contains reference materials that enhance this skill's capabilities.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
References can include:
|
|
8
|
+
- Code examples
|
|
9
|
+
- Style guides
|
|
10
|
+
- Best practices documentation
|
|
11
|
+
- Template files
|
|
12
|
+
- Configuration examples
|
|
13
|
+
|
|
14
|
+
## Guidelines
|
|
15
|
+
|
|
16
|
+
- Keep references concise and actionable
|
|
17
|
+
- Use markdown for documentation
|
|
18
|
+
- Include clear examples
|
|
19
|
+
- Link to external resources when appropriate
|
|
20
|
+
|
|
21
|
+
## Types of References
|
|
22
|
+
|
|
23
|
+
- **examples.md** - Usage examples
|
|
24
|
+
- **style-guide.md** - Coding standards
|
|
25
|
+
- **templates/** - Reusable templates
|
|
26
|
+
- **patterns.md** - Design patterns
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Skill Scripts
|
|
2
|
+
|
|
3
|
+
This directory contains optional helper scripts that support this skill's functionality.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
Scripts here can be:
|
|
8
|
+
- Referenced by the skill for automation
|
|
9
|
+
- Used as examples for users
|
|
10
|
+
- Executed during skill activation
|
|
11
|
+
|
|
12
|
+
## Guidelines
|
|
13
|
+
|
|
14
|
+
- All scripts should be well-documented
|
|
15
|
+
- Include usage examples in comments
|
|
16
|
+
- Make scripts executable (`chmod +x`)
|
|
17
|
+
- Use `#!/bin/bash` or `#!/usr/bin/env python3` shebangs
|
|
18
|
+
|
|
19
|
+
## Adding Scripts
|
|
20
|
+
|
|
21
|
+
1. Create script file (e.g., `analyze.sh`, `process.py`)
|
|
22
|
+
2. Add documentation header
|
|
23
|
+
3. Make executable: `chmod +x script-name.sh`
|
|
24
|
+
4. Test thoroughly before committing
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"skill": {
|
|
3
|
+
"name": "skill-name",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"enabled": true,
|
|
6
|
+
"settings": {
|
|
7
|
+
"verbose": false,
|
|
8
|
+
"autoActivate": true,
|
|
9
|
+
"toolRestrictions": true
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"triggers": {
|
|
13
|
+
"keywords": [
|
|
14
|
+
"example-trigger-1",
|
|
15
|
+
"example-trigger-2"
|
|
16
|
+
],
|
|
17
|
+
"patterns": []
|
|
18
|
+
},
|
|
19
|
+
"tools": {
|
|
20
|
+
"allowed": [
|
|
21
|
+
"Read",
|
|
22
|
+
"Grep",
|
|
23
|
+
"Bash"
|
|
24
|
+
],
|
|
25
|
+
"restricted": []
|
|
26
|
+
},
|
|
27
|
+
"metadata": {
|
|
28
|
+
"author": "Plugin Author",
|
|
29
|
+
"category": "general",
|
|
30
|
+
"tags": []
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Claude Skill Configuration",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"required": ["name", "description"],
|
|
6
|
+
"properties": {
|
|
7
|
+
"name": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"pattern": "^[a-z0-9-]+$",
|
|
10
|
+
"maxLength": 64,
|
|
11
|
+
"description": "Skill identifier (lowercase, hyphens only)"
|
|
12
|
+
},
|
|
13
|
+
"description": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"maxLength": 1024,
|
|
16
|
+
"description": "What the skill does and when to use it"
|
|
17
|
+
},
|
|
18
|
+
"allowed-tools": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "Comma-separated list of allowed tools"
|
|
21
|
+
},
|
|
22
|
+
"version": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"pattern": "^\\d+\\.\\d+\\.\\d+$",
|
|
25
|
+
"description": "Semantic version (x.y.z)"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|