PasswordLab Configuration & Binary Backup and Restore Guide
This guide provides clear instructions for backing up and restoring the PasswordLab configuration file (/etc/passwordlab/passwordlab.json) and the PasswordLab binary (/usr/local/bin/passwordlab). Use these steps for disaster recovery, migration, or regular maintenance.
1. Manual Backup
-
Backup configuration file:
cp /etc/passwordlab/passwordlab.json /root/passwordlab-config-backup-$(date +%Y%m%d).json
-
Backup PasswordLab binary:
cp /usr/local/bin/passwordlab /root/passwordlab-binary-backup-$(date +%Y%m%d)
-
Backup PasswordLab Systemd Service file:
cp /etc/systemd/system/passwordlab.service /root/passwordlab-service-backup-$(date +%Y%m%d).service
-
Verify backups:
ls -lh /root/passwordlab-config-backup-* ls -lh /root/passwordlab-binary-backup-* ls -lh /root/passwordlab-service-backup-*
2. Automated Backup Script
-
Create a backup script:
nano /root/backup-passwordlab-config-binary.sh
-
Script contents:
-
Make the script executable:
chmod +x /root/backup-passwordlab-config-binary.sh
-
Schedule daily backups with cron:
crontab -e
Add this line to run the backup every day at 2:00 AM:
0 2 * * * /root/backup-passwordlab-config-binary.sh
#!/bin/bash
DATE=$(date +%Y%m%d_%H%M%S)
cp /etc/passwordlab/passwordlab.json /root/passwordlab-config-backup-$DATE.json
cp /usr/local/bin/passwordlab /root/passwordlab-binary-backup-$DATE
cp /etc/systemd/system/passwordlab.service /root/passwordlab-service-backup-$DATE.service
# Optional: Remove backups older than 60 days
find /root -name "passwordlab-config-backup-*.json" -mtime +60 -delete
find /root -name "passwordlab-binary-backup-*" -mtime +60 -delete
find /root -name "passwordlab-service-backup-*" -mtime +60 -delete
3. Restore Process
-
Restore configuration file:
mkdir -p /etc/passwordlab cp /root/passwordlab-config-backup-YYYYMMDD.json /etc/passwordlab/passwordlab.json
-
Restore PasswordLab binary:
cp /root/passwordlab-binary-backup-YYYYMMDD /usr/local/bin/passwordlab chown root:root /usr/local/bin/passwordlab chmod 755 /usr/local/bin/passwordlab
-
Reload systemd and restart the service:
systemctl daemon-reload systemctl restart passwordlab systemctl status passwordlab
-
Enable the service to start on boot:
systemctl enable passwordlab
-
Verify restoration:
Check service status: systemctl status passwordlab
Check logs for errors: journalctl -u passwordlab -f
Best Practices
- Store backups in a secure, access-controlled location.
- Test restoration in a staging environment before production.
- Automate and monitor your backup process.
- Retain multiple backup copies for redundancy.