wip
This commit is contained in:
		
							parent
							
								
									ed34d44b2b
								
							
						
					
					
						commit
						1ce95b02ff
					
				
					 9 changed files with 102 additions and 5 deletions
				
			
		
							
								
								
									
										27
									
								
								bundles/archive/files/archive
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								bundles/archive/files/archive
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,27 @@ | ||||||
|  | #!/bin/bash | ||||||
|  | 
 | ||||||
|  | if [[ '$1' == 'perform' ]] | ||||||
|  | then | ||||||
|  |   echo 'NON-DRY RUN' | ||||||
|  |   DRY='' | ||||||
|  | else | ||||||
|  |   echo 'DRY RUN' | ||||||
|  |   DRY='-n' | ||||||
|  | fi | ||||||
|  | 
 | ||||||
|  | % for dir, conf in dirs.items(): | ||||||
|  | # ${dir} | ||||||
|  | gsutil ${'\\'} | ||||||
|  |   -m ${'\\'} | ||||||
|  |   -o 'GSUtil:parallel_process_count=${processes}' ${'\\'} | ||||||
|  |   -o 'GSUtil:parallel_thread_count=${threads}' ${'\\'} | ||||||
|  |   rsync ${'\\'} | ||||||
|  |     $DRY ${'\\'} | ||||||
|  |     -r ${'\\'} | ||||||
|  |     -d ${'\\'} | ||||||
|  |     -e ${'\\'} | ||||||
|  |     -x '${'|'.join(conf['exclude'])}' ${'\\'} | ||||||
|  |     '${dir}' ${'\\'} | ||||||
|  |     'gs://${bucket}/${node.name}${dir}' | ||||||
|  | 
 | ||||||
|  | % endfor | ||||||
							
								
								
									
										16
									
								
								bundles/archive/items.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								bundles/archive/items.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,16 @@ | ||||||
|  | assert node.has_bundle('gcloud') | ||||||
|  | 
 | ||||||
|  | files['/opt/archive'] = { | ||||||
|  |     'content_type': 'mako', | ||||||
|  |     'mode': '700', | ||||||
|  |     'context': { | ||||||
|  |         'dirs': node.metadata.get('archive'), | ||||||
|  |         'bucket': node.metadata.get('gcloud/bucket'), | ||||||
|  |         'processes': 4, | ||||||
|  |         'threads': 16, | ||||||
|  |     }, | ||||||
|  |     'needs': [ | ||||||
|  |         'bundle:gcloud', | ||||||
|  |     ], | ||||||
|  | } | ||||||
|  |      | ||||||
							
								
								
									
										4
									
								
								bundles/archive/metadata.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								bundles/archive/metadata.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,4 @@ | ||||||
|  | defaults = { | ||||||
|  |     'backup': [], | ||||||
|  |     'archive': {}, | ||||||
|  | } | ||||||
|  | @ -2,4 +2,6 @@ | ||||||
| gcloud projects add-iam-policy-binding sublimity-182017 --member 'serviceAccount:backup@sublimity-182017.iam.gserviceaccount.com' --role 'roles/storage.objectViewer' | gcloud projects add-iam-policy-binding sublimity-182017 --member 'serviceAccount:backup@sublimity-182017.iam.gserviceaccount.com' --role 'roles/storage.objectViewer' | ||||||
| gcloud projects add-iam-policy-binding sublimity-182017 --member 'serviceAccount:backup@sublimity-182017.iam.gserviceaccount.com' --role 'roles/storage.objectCreator' | gcloud projects add-iam-policy-binding sublimity-182017 --member 'serviceAccount:backup@sublimity-182017.iam.gserviceaccount.com' --role 'roles/storage.objectCreator' | ||||||
| gsutil -o "GSUtil:parallel_process_count=3" -o GSUtil:parallel_thread_count=4 -m rsync -r -d -e /var/vmail gs://sublimity-backup/mailserver | gsutil -o "GSUtil:parallel_process_count=3" -o GSUtil:parallel_thread_count=4 -m rsync -r -d -e /var/vmail gs://sublimity-backup/mailserver | ||||||
|  | gsutil config | ||||||
|  | gsutil versioning set on gs://sublimity-backup | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
							
								
								
									
										31
									
								
								bundles/nextcloud/metadata.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								bundles/nextcloud/metadata.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,31 @@ | ||||||
|  | defaults = { | ||||||
|  |     'archive': {  | ||||||
|  |         '/var/lib/nextcloud/': { | ||||||
|  |             'exclude': [ | ||||||
|  |                 '^appdata_', | ||||||
|  |                 '^updater-', | ||||||
|  |                 '^nextcloud\.log', | ||||||
|  |                 '^updater\.log', | ||||||
|  |                 '^[^/]+/cache', | ||||||
|  |                 '^[^/]+/files_versions', | ||||||
|  |                 '^[^/]+/files_trashbin', | ||||||
|  |             ], | ||||||
|  |         } | ||||||
|  |     }, | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @metadata_reactor.provides( | ||||||
|  |     'archive', | ||||||
|  | ) | ||||||
|  | def exclude_hidden_files_from_archive(metadata): | ||||||
|  |     return { | ||||||
|  |         'archive': { | ||||||
|  |             dir: { | ||||||
|  |                 'exclude': [ | ||||||
|  |                     '^\..*', | ||||||
|  |                     '/\..*', | ||||||
|  |                 ], | ||||||
|  |             } for dir, conf in metadata.get('archive').items() | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | @ -1,9 +1,5 @@ | ||||||
| { | { | ||||||
|     'metadata': { |     'metadata': { | ||||||
|         'dns': {}, |         'dns': {}, | ||||||
|         'gcloud': { |  | ||||||
|             'service_account': 'backup', |  | ||||||
|             'project': 'sublimity-182017', |  | ||||||
|         }, |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										8
									
								
								groups/applications/archive.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								groups/applications/archive.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,8 @@ | ||||||
|  | { | ||||||
|  |     'supergroups': [ | ||||||
|  |         'gcloud', | ||||||
|  |     ], | ||||||
|  |     'bundles': [ | ||||||
|  |         'archive', | ||||||
|  |     ], | ||||||
|  | } | ||||||
							
								
								
									
										12
									
								
								groups/applications/gcloud.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								groups/applications/gcloud.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,12 @@ | ||||||
|  | { | ||||||
|  |     'bundles': [ | ||||||
|  |         'gcloud', | ||||||
|  |     ], | ||||||
|  |     'metadata': { | ||||||
|  |         'gcloud': { | ||||||
|  |             'service_account': 'backup', | ||||||
|  |             'bucket': 'sublimity-backup', | ||||||
|  |             'project': 'sublimity-182017', | ||||||
|  |         }, | ||||||
|  |     }, | ||||||
|  | } | ||||||
|  | @ -2,12 +2,13 @@ | ||||||
|     'hostname': '10.0.0.2', |     'hostname': '10.0.0.2', | ||||||
|     'groups': [ |     'groups': [ | ||||||
|         'debian-10', |         'debian-10', | ||||||
|  |         'archive', | ||||||
|     ], |     ], | ||||||
|     'bundles': [ |     'bundles': [ | ||||||
|         'gitea', |         'gitea', | ||||||
|  |         'nextcloud', | ||||||
|         'postgresql', |         'postgresql', | ||||||
|         'wireguard', |         'wireguard', | ||||||
|         'gcloud', |  | ||||||
|     ], |     ], | ||||||
|     'metadata': { |     'metadata': { | ||||||
|         'network': { |         'network': { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 mwiegand
						mwiegand