mirror of
https://github.com/kevinveenbirkenbach/docker-volume-backup.git
synced 2024-11-24 17:21:03 +01:00
Removed backup over kevinveenbirkenbach/alpine-rsync
This commit is contained in:
parent
2776c35da6
commit
5bb95d61f4
@ -43,36 +43,33 @@ for volume_name in volume_names:
|
|||||||
print('skipped due to no running containers using this volume.');
|
print('skipped due to no running containers using this volume.');
|
||||||
else:
|
else:
|
||||||
container=containers[0]
|
container=containers[0]
|
||||||
source_path_command="docker inspect --format \"{{ range .Mounts }}{{ if eq .Type \\\"volume\\\"}}{{ if eq .Name \\\"" + volume_name +"\\\"}}{{ println .Destination }}{{ end }}{{ end }}{{ end }}\" \""+ container +"\""
|
source_path="/var/lib/docker/volumes/" + volume_name + "/_data"
|
||||||
source_path_command_result_filtered=list(filter(None, bash(source_path_command)))
|
destination_path=backup_repository_folder+"latest/"+ volume_name
|
||||||
for source_path in source_path_command_result_filtered:
|
log_path=backup_repository_folder + "log.txt"
|
||||||
destination_path=backup_repository_folder+"latest/"+ volume_name
|
backup_dir_path=backup_repository_folder + "diffs/"+ backup_time + "/" + volume_name
|
||||||
log_path=backup_repository_folder + "log.txt"
|
databases_entries=databases.loc[databases['container'] == container];
|
||||||
backup_dir_path=backup_repository_folder + "diffs/"+ backup_time + "/" + volume_name
|
if len(databases_entries) == 1:
|
||||||
|
print("Backup database...")
|
||||||
databases_entries=databases.loc[databases['container'] == container];
|
sql_destination_path=destination_path + "/sql"
|
||||||
if len(databases_entries) == 1:
|
sql_backup_dir_path=backup_dir_path + "/sql"
|
||||||
print("Backup database...")
|
sql_destination_dir_file_path=sql_destination_path+"/backup.sql"
|
||||||
sql_destination_path=destination_path + "/sql"
|
pathlib.Path(sql_destination_path).mkdir(parents=True, exist_ok=True)
|
||||||
sql_backup_dir_path=backup_dir_path + "/sql"
|
pathlib.Path(sql_backup_dir_path).mkdir(parents=True, exist_ok=True)
|
||||||
sql_destination_dir_file_path=sql_destination_path+"/backup.sql"
|
database_entry=databases_entries.iloc[0];
|
||||||
pathlib.Path(sql_destination_path).mkdir(parents=True, exist_ok=True)
|
database_backup_command="docker exec "+ database_entry["container"] + " /usr/bin/mysqldump -u "+ database_entry["username"] + " -p"+ database_entry["password"] + " "+ database_entry["database"] + " > " + sql_destination_dir_file_path
|
||||||
pathlib.Path(sql_backup_dir_path).mkdir(parents=True, exist_ok=True)
|
print_bash(database_backup_command)
|
||||||
database_entry=databases_entries.iloc[0];
|
print_bash("cp -v " + sql_destination_dir_file_path + " " + sql_backup_dir_path)
|
||||||
database_backup_command="docker exec "+ database_entry["container"] + " /usr/bin/mysqldump -u "+ database_entry["username"] + " -p"+ database_entry["password"] + " "+ database_entry["database"] + " > " + sql_destination_dir_file_path
|
else:
|
||||||
print_bash(database_backup_command)
|
print("Backup files...")
|
||||||
print_bash("cp -v " + sql_destination_dir_file_path + " " + sql_backup_dir_path)
|
files_destination_path=destination_path + "/files"
|
||||||
else:
|
files_backup_dir_path=backup_dir_path + "/files"
|
||||||
print("Backup files...")
|
pathlib.Path(files_backup_dir_path).mkdir(parents=True, exist_ok=True)
|
||||||
files_destination_path=destination_path + "/files"
|
pathlib.Path(files_destination_path).mkdir(parents=True, exist_ok=True)
|
||||||
files_backup_dir_path=backup_dir_path + "/files"
|
print("stop containers...");
|
||||||
pathlib.Path(files_backup_dir_path).mkdir(parents=True, exist_ok=True)
|
print_bash("docker stop " + list_to_string(containers))
|
||||||
pathlib.Path(files_destination_path).mkdir(parents=True, exist_ok=True)
|
print_bash("rsync -abP --delete --delete-excluded --log-file=" + log_path +" --backup-dir=" + files_backup_dir_path +" '"+ source_path +"/' " + files_destination_path)
|
||||||
print("stop containers...");
|
print("start containers...")
|
||||||
print_bash("docker stop " + list_to_string(containers))
|
print_bash("docker start " + list_to_string(containers))
|
||||||
print_bash("docker run --rm --volumes-from " + container + " -v "+backups_folder+":"+ backups_folder +" \"kevinveenbirkenbach/alpine-rsync\" sh -c \"rsync -abP --delete --delete-excluded --log-file=" + log_path +" --backup-dir=" + files_backup_dir_path +" '"+ source_path +"/' " + files_destination_path +"\"")
|
|
||||||
print("start containers...")
|
|
||||||
print_bash("docker start " + list_to_string(containers))
|
|
||||||
print("end backup routine for volume:" + volume_name)
|
print("end backup routine for volume:" + volume_name)
|
||||||
print('finished volume backups.')
|
print('finished volume backups.')
|
||||||
print('restart docker service...')
|
print('restart docker service...')
|
||||||
|
Loading…
Reference in New Issue
Block a user