7.9 KiB
SLMS Project Backup Guide
Overview
This guide provides comprehensive instructions for backing up the SLMS project and all related configurations before performing the repository restructure.
Quick Start
To create a backup, run:
cd /d %PROJECT_ROOT%
scripts\backup_project.bat
This will create a timestamped backup directory containing:
- Complete project files
- Jenkins configuration backup
- SonarQube configuration backup
- Backup summary and verification checklist
Backup Components
1. Project Files Backup
What's Included:
- Source code (src/, backend/, android/)
- Build configurations (pom.xml, build.gradle, settings.gradle)
- Scripts (scripts/)
- Documentation (docs/)
- Configuration files (Jenkinsfile, sonar-project.properties)
What's Excluded:
- Build artifacts (target/, build/)
- IDE files (.idea/, .vscode/)
- Git history (.git/)
- Temporary files (*.tmp, *.log)
Manual Backup Alternative:
REM Create backup directory
mkdir backup_manual
REM Copy project files
xcopy /E /I /H /Y /EXCLUDE:backup_exclude.txt . backup_manual\project
2. Jenkins Configuration Backup
Automated Backup: The script backs up:
- Jenkinsfile
Manual Steps Required:
Export Job Configuration
-
Via Jenkins UI:
- Navigate to:
http://localhost:8080/job/YOUR_JOB_NAME/config.xml - Save the XML file
- Navigate to:
-
Via Jenkins CLI:
java -jar jenkins-cli.jar -s http://localhost:8080/ -auth USER:TOKEN get-job SLMS > job-config.xml
Export Credentials
Document the following credential IDs:
gitea-credentials- Local Gitea accesseducoder-credentials- 头歌 repository accesssonarqube-token- SonarQube authentication
Note: Credential values cannot be exported for security reasons. Document the IDs and be prepared to recreate them.
Export System Configuration
-
Global Tool Configuration:
- Navigate to:
http://localhost:8080/configureTools/ - Document JDK, Maven, Gradle installations
- Navigate to:
-
System Configuration:
- Navigate to:
http://localhost:8080/configure/ - Document environment variables and system settings
- Navigate to:
Export Installed Plugins
java -jar jenkins-cli.jar -s http://localhost:8080/ -auth USER:TOKEN list-plugins > plugins.txt
3. SonarQube Configuration Backup
Automated Backup: The script backs up:
- sonar-project.properties
Manual Steps Required:
Export Project Settings
-
Via SonarQube UI:
- Navigate to:
http://localhost:9000/dashboard?id=slms - Go to: Project Settings > General Settings
- Document all custom settings
- Navigate to:
-
Via SonarQube API:
curl -u YOUR_TOKEN: http://localhost:9000/api/settings/values?component=slms > sonar-settings.json
Export Quality Gates
-
Via SonarQube UI:
- Navigate to:
http://localhost:9000/quality_gates - Document quality gate name and conditions
- Navigate to:
-
Via SonarQube API:
curl -u YOUR_TOKEN: http://localhost:9000/api/qualitygates/show?name=YOUR_GATE > qualitygate.json
Export Quality Profiles
-
Via SonarQube UI:
- Navigate to:
http://localhost:9000/profiles - Document active profiles for Java
- Navigate to:
-
Via SonarQube API:
curl -u YOUR_TOKEN: http://localhost:9000/api/qualityprofiles/search > profiles.json
Export Webhooks
-
Via SonarQube UI:
- Navigate to:
http://localhost:9000/project/webhooks?id=slms - Document webhook URLs and configurations
- Navigate to:
-
Via SonarQube API:
curl -u YOUR_TOKEN: http://localhost:9000/api/webhooks/list?project=slms > webhooks.json
Backup Verification
After creating the backup, verify completeness using the checklist:
type backup_TIMESTAMP\VERIFICATION_CHECKLIST.md
Critical Verification Steps
-
Check Backup Size:
dir backup_TIMESTAMP /sExpected size: 50-200 MB (depending on project size)
-
Verify Key Files:
dir backup_TIMESTAMP\project\pom.xml dir backup_TIMESTAMP\project\Jenkinsfile dir backup_TIMESTAMP\project\sonar-project.properties -
Test File Accessibility:
- Open a few source files to ensure they're readable
- Check that no files are corrupted
Restoration Instructions
Restore Project Files
REM Navigate to desired restoration location
cd /d C:\restoration_location
REM Restore all project files
xcopy /E /I /H /Y backup_TIMESTAMP\project\* .
Restore Jenkins Configuration
-
Restore Jenkinsfile:
copy backup_TIMESTAMP\jenkins\Jenkinsfile.backup Jenkinsfile -
Import Job Configuration:
- Via Jenkins UI: New Item > Copy from existing job
- Via Jenkins CLI:
java -jar jenkins-cli.jar -s http://localhost:8080/ create-job SLMS < job-config.xml
-
Recreate Credentials:
- Navigate to:
http://localhost:8080/credentials/ - Add credentials with the same IDs as documented
- Navigate to:
Restore SonarQube Configuration
-
Restore Project Properties:
copy backup_TIMESTAMP\sonarqube\sonar-project.properties.backup sonar-project.properties -
Recreate Project:
- Navigate to:
http://localhost:9000/projects/create - Use project key:
slms(orslms:slmsif that was the original)
- Navigate to:
-
Restore Quality Gates and Profiles:
- Apply documented quality gates
- Activate documented quality profiles
-
Recreate Webhooks:
- Add webhooks with documented URLs
Backup Storage Recommendations
Short-term Storage (During Restructure)
- Keep backup in a separate directory on the same machine
- Location:
C:\backups\slms\or similar - Duration: Until restructure is verified successful (1-2 weeks)
Long-term Storage (Archive)
- Compress backup directory:
tar -czf slms_backup_%date%.tar.gz backup_TIMESTAMP\ - Store in:
- Network drive
- External hard drive
- Cloud storage (if permitted)
- Duration: 3-6 months
Troubleshooting
Backup Script Fails
Issue: Permission denied errors
Solution:
REM Run as administrator
runas /user:Administrator "cmd /c scripts\backup_project.bat"
Issue: Disk space insufficient
Solution:
- Check available space:
dir C:\ | findstr "bytes free" - Clean up unnecessary files
- Use external drive for backup
Incomplete Backup
Issue: Some files not copied
Solution:
- Check backup_exclude.txt for unintended exclusions
- Manually copy missing files
- Verify file permissions
Jenkins Export Fails
Issue: Cannot access Jenkins CLI
Solution:
- Download Jenkins CLI:
http://localhost:8080/jnlpJars/jenkins-cli.jar - Verify Jenkins is running
- Check authentication credentials
SonarQube Export Fails
Issue: API authentication fails
Solution:
- Generate new token:
http://localhost:9000/account/security - Use token in curl commands:
-u TOKEN: - Verify SonarQube is running
Backup Checklist
Before proceeding with restructure, ensure:
- Backup script executed successfully
- Project files backed up completely
- Jenkinsfile backed up
- Jenkins job configuration exported
- Jenkins credentials documented
- sonar-project.properties backed up
- SonarQube project settings documented
- SonarQube quality gates documented
- Backup verification checklist completed
- Backup stored in safe location
- Restoration process understood
Next Steps
After completing the backup:
- Review backup summary:
backup_TIMESTAMP\BACKUP_SUMMARY.md - Complete verification checklist:
backup_TIMESTAMP\VERIFICATION_CHECKLIST.md - Store backup in safe location
- Proceed with task 2: Modify Jenkinsfile
Support
If you encounter issues during backup:
- Check error messages in console output
- Review this guide's troubleshooting section
- Verify system requirements (disk space, permissions)
- Document any issues for future reference
Last Updated: 2025-11-26 Version: 1.0