Fix: Service management errors in sigvild-gallery restoration
- Fix Unix timestamp conversion in restore.yml using proper strftime syntax - Add service existence check before stopping sigvild-gallery service - Fix systemd service template environment variable syntax error - Add proper error handling for fresh deployments where service doesn't exist yet Resolves service management failures during restoration on fresh VPS installations.
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
|
||||
- name: Display found backup files
|
||||
debug:
|
||||
msg: "Found backup: {{ item.path }} ({{ (item.size / 1024 / 1024) | round(2) }}MB, {{ item.mtime | to_datetime }})"
|
||||
msg: "Found backup: {{ item.path }} ({{ (item.size / 1024 / 1024) | round(2) }}MB, {{ '%Y-%m-%d %H:%M:%S' | strftime(item.mtime | int) }})"
|
||||
loop: "{{ backup_files.files | sort(attribute='mtime') }}"
|
||||
when: backup_files.files | length > 0
|
||||
|
||||
@@ -33,6 +33,15 @@
|
||||
- existing_data.stat.exists
|
||||
- backup_files.files | length > 0
|
||||
|
||||
- name: Skip restore due to existing data
|
||||
debug:
|
||||
msg:
|
||||
- "🛡️ SAFETY: Restore skipped to protect existing data"
|
||||
- "Remove {{ sigvild_gallery_data_dir }}/data.db manually to enable restore"
|
||||
when:
|
||||
- existing_data.stat.exists
|
||||
- backup_files.files | length > 0
|
||||
|
||||
- name: Restore from latest backup
|
||||
block:
|
||||
- name: Get latest backup file
|
||||
@@ -45,12 +54,22 @@
|
||||
- "Restoring from latest backup: {{ latest_backup | basename }}"
|
||||
- "Target directory: {{ sigvild_gallery_data_dir }}"
|
||||
|
||||
- name: Check if sigvild-gallery service exists
|
||||
stat:
|
||||
path: /etc/systemd/system/sigvild-gallery.service
|
||||
register: sigvild_service_file
|
||||
|
||||
- name: Stop sigvild-gallery service before restoration
|
||||
systemd:
|
||||
name: sigvild-gallery
|
||||
state: stopped
|
||||
register: service_stopped_for_restore
|
||||
ignore_errors: true # Service might not exist on fresh deployment
|
||||
when: sigvild_service_file.stat.exists
|
||||
ignore_errors: true
|
||||
|
||||
- name: Display service stop status
|
||||
debug:
|
||||
msg: "{{ 'Service stopped for restoration' if sigvild_service_file.stat.exists else 'Service does not exist yet - skipping stop' }}"
|
||||
|
||||
- name: Upload backup to remote server
|
||||
copy:
|
||||
@@ -116,11 +135,13 @@
|
||||
- "Restored data size: {{ restored_size.stdout }}"
|
||||
- "Location: {{ sigvild_gallery_data_dir }}"
|
||||
|
||||
when: backup_files.files | length > 0
|
||||
when:
|
||||
- backup_files.files | length > 0
|
||||
- not existing_data.stat.exists
|
||||
|
||||
- name: No backup available message
|
||||
debug:
|
||||
msg:
|
||||
- "ℹ️ No backup files found - starting with fresh installation"
|
||||
- "Data directory will be created empty: {{ sigvild_gallery_data_dir }}"
|
||||
when: backup_files.files | length == 0
|
||||
when: backup_files.files | length == 0
|
||||
|
||||
Reference in New Issue
Block a user