15 lines
		
	
	
		
			797 B
		
	
	
	
		
			Desktop File
		
	
	
	
	
	
			
		
		
	
	
			15 lines
		
	
	
		
			797 B
		
	
	
	
		
			Desktop File
		
	
	
	
	
	
[Unit]
 | 
						|
Description=Snapshot %i container
 | 
						|
Requisite=systemd-nspawn@%i.service
 | 
						|
Wants=mnt-containers.mount
 | 
						|
After=systemd-nspawn@%i.service mnt-containers.mount
 | 
						|
 | 
						|
[Service]
 | 
						|
Type=oneshot
 | 
						|
ExecStartPre=/usr/bin/machinectl stop %i
 | 
						|
# Hereunder is a bit gross, but we need to make sure container is entirely stopped / 5 sec should be sufficient, but we have a problem with mail container; perhaps this sleep is too late anyway...
 | 
						|
ExecStart=/usr/bin/bash -c 'sleep 10 && /usr/bin/btrfs subvolume snapshot -r /mnt/containers/%i/current /mnt/containers/%i/$$(date +%%Y%%m%%d)'
 | 
						|
# As we now get random issues post snap (containers do not always restart...), we add another sleep... Real gros...
 | 
						|
#ExecStartPost=/usr/bin/machinectl start %i
 | 
						|
ExecStartPost=/usr/bin/bash -c 'sleep 10 && /usr/bin/machinectl start %i'
 |