2020
2121
2222class BackupProvider (NamedTuple ):
23+ name : str
2324 patterns : list [str ]
2425 backup_method : Callable [[Container ], str ]
2526 file_extension : str
@@ -128,17 +129,22 @@ def backup_redis(container: Container) -> str:
128129
129130BACKUP_PROVIDERS : list [BackupProvider ] = [
130131 BackupProvider (
132+ name = "postgres" ,
131133 patterns = ["postgres" , "tensorchord/pgvecto-rs" , "nextcloud/aio-postgresql" ],
132134 backup_method = backup_psql ,
133135 file_extension = "sql" ,
134136 ),
135137 BackupProvider (
138+ name = "mysql" ,
136139 patterns = ["mysql" , "mariadb" , "linuxserver/mariadb" ],
137140 backup_method = backup_mysql ,
138141 file_extension = "sql" ,
139142 ),
140143 BackupProvider (
141- patterns = ["redis" ], backup_method = backup_redis , file_extension = "rdb"
144+ name = "redis" ,
145+ patterns = ["redis" ],
146+ backup_method = backup_redis ,
147+ file_extension = "rdb" ,
142148 ),
143149]
144150
@@ -194,13 +200,15 @@ def backup(now: datetime) -> None:
194200 backup_command = backup_provider .backup_method (container )
195201 _ , output = container .exec_run (backup_command , stream = True , demux = True )
196202
203+ description = f"{ container .name } ({ backup_provider .name } )"
204+
197205 with open_file_compressed (
198206 backup_temp_file_path , COMPRESSION
199207 ) as backup_temp_file :
200208 with tqdm .wrapattr (
201209 backup_temp_file ,
202210 method = "write" ,
203- desc = container . name ,
211+ desc = description ,
204212 disable = not SHOW_PROGRESS ,
205213 ) as f :
206214 for stdout , _ in output :
@@ -211,7 +219,7 @@ def backup(now: datetime) -> None:
211219 os .replace (backup_temp_file_path , backup_file )
212220
213221 if not SHOW_PROGRESS :
214- print (container . name )
222+ print (description )
215223
216224 backed_up_containers .append (container .name )
217225
0 commit comments