X Tutup
Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 915f6a3

Browse files
committed
Backup: Updated to stop/start Plexdrive4 and Plexdrive5
1 parent 54c3f77 commit 915f6a3

File tree

1 file changed

+75
-39
lines changed

1 file changed

+75
-39
lines changed

roles/backup/tasks/main.yml

Lines changed: 75 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -169,23 +169,41 @@
169169
message: "Stopped Docker containers."
170170
when: (cloudbox_managed_containers.stdout | trim | length > 0)
171171

172-
# Stop Plexdrive
172+
# Stop Plexdrive 4
173173

174-
- name: Check if 'plexdrive.service' exists
174+
- name: Check if 'plexdrive4.service' exists
175175
stat:
176-
path: "/etc/systemd/system/plexdrive.service"
177-
register: plexdrive_service
176+
path: "/etc/systemd/system/plexdrive4.service"
177+
register: plexdrive4_service
178178

179-
- name: Get plexdrive service state
179+
- name: Get 'plexdrive4' service state
180180
set_fact:
181-
plexdrive_service_running: "{{ (services['plexdrive.service'] is defined) and (services['plexdrive.service']['state'] == 'running') }}"
182-
when: (plexdrive_service.stat.exists)
181+
plexdrive4_service_running: "{{ (services['plexdrive4.service'] is defined) and (services['plexdrive4.service']['state'] == 'running') }}"
182+
when: (plexdrive4_service is defined) and (plexdrive4_service.stat.exists)
183183

184-
- name: Stop plexdrive service
184+
- name: Stop 'plexdrive4' service
185185
systemd:
186-
name: plexdrive
186+
name: plexdrive4
187187
state: stopped
188-
when: (plexdrive_service.stat.exists) and (plexdrive_service_running)
188+
when: (plexdrive4_service is defined) and (plexdrive4_service.stat.exists) and (plexdrive4_service_running)
189+
190+
# Stop Plexdrive 5
191+
192+
- name: Check if 'plexdrive5.service' exists
193+
stat:
194+
path: "/etc/systemd/system/plexdrive5.service"
195+
register: plexdrive5_service
196+
197+
- name: Get 'plexdrive5' service state
198+
set_fact:
199+
plexdrive5_service_running: "{{ (services['plexdrive5.service'] is defined) and (services['plexdrive5.service']['state'] == 'running') }}"
200+
when: (plexdrive5_service is defined) and (plexdrive5_service.stat.exists)
201+
202+
- name: Stop 'plexdrive5' service
203+
systemd:
204+
name: plexdrive5
205+
state: stopped
206+
when: (plexdrive5_service is defined) and (plexdrive5_service.stat.exists) and (plexdrive5_service_running)
189207

190208
# Stop Cloudplow
191209

@@ -194,16 +212,16 @@
194212
path: "/etc/systemd/system/cloudplow.service"
195213
register: cloudplow_service
196214

197-
- name: Get cloudplow service state
215+
- name: Get 'cloudplow' service state
198216
set_fact:
199217
cloudplow_service_running: "{{ (services['cloudplow.service'] is defined) and (services['cloudplow.service']['state'] == 'running') }}"
200218
when: (cloudplow_service.stat.exists)
201219

202-
- name: Stop cloudplow service
220+
- name: Stop 'cloudplow' service
203221
systemd:
204222
name: cloudplow
205223
state: stopped
206-
when: (cloudplow_service.stat.exists) and (cloudplow_service_running)
224+
when: (cloudplow_service is defined) and (cloudplow_service.stat.exists) and (cloudplow_service_running)
207225

208226
# Create snapshot
209227

@@ -228,19 +246,24 @@
228246

229247
when: (use_snapshot)
230248

249+
# Start Plexdrive and Docker containers when snapshot is enabled
231250

232-
# Start Plexdrive and containers when snapshot is enabled
233-
234-
- name: Snapshot | Start plexdrive and containers
251+
- name: Snapshot | Start Plexdrive and Docker containers
235252
block:
236253

237-
- name: "Snapshot | Start plexdrive service"
254+
- name: "Snapshot | Start 'plexdrive4' service"
238255
systemd:
239-
name: plexdrive
256+
name: plexdrive4
240257
state: started
241-
when: (plexdrive_service.stat.exists) and (plexdrive_service_running)
258+
when: (plexdrive4_service is defined) and (plexdrive4_service.stat.exists) and (plexdrive4_service_running)
242259

243-
- name: "Snapshot | Wait for 5 seconds before starting containers"
260+
- name: "Snapshot | Start 'plexdrive5' service"
261+
systemd:
262+
name: plexdrive5
263+
state: started
264+
when: (plexdrive5_service is defined) and (plexdrive5_service.stat.exists) and (plexdrive5_service_running)
265+
266+
- name: "Snapshot | Wait for 5 seconds before starting Docker containers"
244267
wait_for:
245268
timeout: 5
246269

@@ -296,15 +319,16 @@
296319
shell: btrfs subvolume delete /btrfs/snapshots/root &> /dev/null || true
297320
when: (use_snapshot) and (snapshot_type == 'btrfs')
298321

299-
- name: Check if tar files were created
322+
- name: Check if tarball files were created
300323
find:
301324
paths: "{{ local.destination }}/opt/"
302325
file_type: file
303326
patterns: '*.tar'
304327
register: dir_files2
305328

306-
- name: Abort backup when tar creation fails
307-
fail: msg="There must have been an issue during the tar creation tasks as they are missing in '{{ local.destination }}/opt/'"
329+
- name: Abort backup when the creation of tarball files fails
330+
fail:
331+
msg: "There must have been an issue during the tarball creation tasks as they are missing in '{{ local.destination }}/opt/'"
308332
when: (dir_files2.matched|int == 0)
309333

310334
- name: "Remove '{{ local.destination }}.old'"
@@ -330,18 +354,24 @@
330354
message: "Backup created. Total size = {{ backup_size }}."
331355
ignore_errors: yes
332356

333-
# Start Plexdrive and containers when snapshot is not enabled
357+
# Start Plexdrive and Docker containers when snapshot is not enabled
334358

335-
- name: Start plexdrive and containers
359+
- name: Start Plexdrive and Docker Containers
336360
block:
337361

338-
- name: "Start plexdrive service"
362+
- name: "Start 'plexdrive4' service"
363+
systemd:
364+
name: plexdrive4
365+
state: started
366+
when: (plexdrive4_service is defined) and (plexdrive4_service.stat.exists) and (plexdrive4_service_running)
367+
368+
- name: "Start 'plexdrive5' service"
339369
systemd:
340-
name: plexdrive
370+
name: plexdrive5
341371
state: started
342-
when: (plexdrive_service.stat.exists) and (plexdrive_service_running)
372+
when: (plexdrive5_service is defined) and (plexdrive5_service.stat.exists) and (plexdrive5_service_running)
343373

344-
- name: "Wait for 5 seconds before starting containers"
374+
- name: "Wait for 5 seconds before starting Docker containers"
345375
wait_for:
346376
timeout: 5
347377

@@ -363,7 +393,7 @@
363393
wait_for:
364394
timeout: 10
365395

366-
- name: "Reset folder ownership"
396+
- name: "Reset folder ownership of '{{ local.destination }}/'"
367397
shell: "chown -R {{ user }}:{{ user }} {{ local.destination }}/"
368398
args:
369399
warn: no
@@ -474,11 +504,11 @@
474504
vars:
475505
message: "Finished Cloudbox {{ use_snapshot | ternary('(snapshot-enabled) ','') }}backup task in {{ total_time }} minutes."
476506

477-
- name: "Start cloudplow service"
507+
- name: "Start 'cloudplow' service"
478508
systemd:
479509
name: cloudplow
480510
state: started
481-
when: (cloudplow_service.stat.exists) and (cloudplow_service_running)
511+
when: (cloudplow_service is defined) and (cloudplow_service.stat.exists) and (cloudplow_service_running)
482512

483513
- name: "Remove {{ local.destination }}"
484514
file:
@@ -495,21 +525,27 @@
495525
shell: btrfs subvolume delete /btrfs/snapshots/root &> /dev/null || true
496526
when: (use_snapshot) and (snapshot_type == 'btrfs')
497527

498-
- name: "Reset folder ownership"
528+
- name: "Reset folder ownership of '{{ local.destination }}/'"
499529
shell: "chown -R {{ user }}:{{ user }} {{ local.destination }}/"
500530
args:
501531
warn: no
502532

503-
- name: Start plexdrive and containers
533+
- name: Start Plexdrive and Docker Containers
504534
block:
505535

506-
- name: "Start plexdrive service"
536+
- name: "Start 'plexdrive4' service"
537+
systemd:
538+
name: plexdrive4
539+
state: started
540+
when: (plexdrive4_service is defined) and (plexdrive4_service.stat.exists) and (plexdrive4_service_running)
541+
542+
- name: "Start 'plexdrive5' service"
507543
systemd:
508-
name: plexdrive
544+
name: plexdrive5
509545
state: started
510-
when: (plexdrive_service is defined) and (plexdrive_service.stat.exists) and (plexdrive_service_running)
546+
when: (plexdrive5_service is defined) and (plexdrive5_service.stat.exists) and (plexdrive5_service_running)
511547

512-
- name: "Wait for 5 seconds before starting containers"
548+
- name: "Wait for 5 seconds before starting Docker containers"
513549
wait_for:
514550
timeout: 5
515551

@@ -520,7 +556,7 @@
520556

521557
when: (not use_snapshot)
522558

523-
- name: "Start cloudplow service"
559+
- name: "Start 'cloudplow' service"
524560
systemd:
525561
name: cloudplow
526562
state: started

0 commit comments

Comments
 (0)
X Tutup