mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-25 06:01:04 +01:00
added paths for ssd and hdd as parameter
This commit is contained in:
parent
678f0fa999
commit
19f368556e
@ -45,30 +45,40 @@ def pause_and_move(storage_path,volume):
|
|||||||
|
|
||||||
start_containers(containers)
|
start_containers(containers)
|
||||||
|
|
||||||
# Path on the SSD where data will be moved
|
if __name__ == "__main__":
|
||||||
ssd_path = "/path/to/ssd"
|
# Argument parser setup
|
||||||
hdd_path = "/path/to/hdd"
|
parser = argparse.ArgumentParser(description='Migrate Docker volumes to SSD or HDD based on container image.')
|
||||||
|
parser.add_argument('--ssd_path', type=str, required=True, help='Path to the SSD storage')
|
||||||
|
parser.add_argument('--hdd_path', type=str, required=True, help='Path to the HDD storage')
|
||||||
|
|
||||||
# List all Docker volumes
|
# Parse arguments
|
||||||
volumes = run_command("docker volume ls -q").splitlines()
|
args = parser.parse_args()
|
||||||
|
|
||||||
for volume in volumes:
|
# Set paths from arguments
|
||||||
# List all containers using this volume
|
ssd_path = args.ssd_path
|
||||||
containers = run_command(f"docker ps -q --filter volume={volume}").splitlines()
|
hdd_path = args.hdd_path
|
||||||
volume_path = get_volume_path(volume)
|
|
||||||
if is_symbolic_link(volume_path):
|
|
||||||
print(f"Skipped Volume {volume}. The storage path {volume_path} is a symbolic link.")
|
|
||||||
|
|
||||||
for container in containers:
|
# List all Docker volumes
|
||||||
# Get the image of the container
|
volumes = run_command("docker volume ls -q").splitlines()
|
||||||
image = get_image(container)
|
|
||||||
|
|
||||||
# Check if the image contains "postgres" or "mariadb"
|
for volume in volumes:
|
||||||
if is_database(image):
|
# List all containers using this volume
|
||||||
print(f"Container {container} with database image {image} found, using volume {volume}.")
|
containers = run_command(f"docker ps -q --filter volume={volume}").splitlines()
|
||||||
pause_and_move(ssd_path,volume)
|
volume_path = get_volume_path(volume)
|
||||||
else:
|
if is_symbolic_link(volume_path):
|
||||||
print(f"Container {container} with file image {image} found, using volume {volume}.")
|
print(f"Skipped Volume {volume}. The storage path {volume_path} is a symbolic link.")
|
||||||
pause_and_move(hdd_path,volume)
|
|
||||||
|
for container in containers:
|
||||||
|
# Get the image of the container
|
||||||
|
image = get_image(container)
|
||||||
|
|
||||||
|
# Check if the image contains "postgres" or "mariadb"
|
||||||
|
if is_database(image):
|
||||||
|
print(f"Container {container} with database image {image} found, using volume {volume}.")
|
||||||
|
pause_and_move(ssd_path,volume)
|
||||||
|
else:
|
||||||
|
print(f"Container {container} with file image {image} found, using volume {volume}.")
|
||||||
|
pause_and_move(hdd_path,volume)
|
||||||
|
|
||||||
|
print("Operation completed.")
|
||||||
|
|
||||||
print("Operation completed.")
|
|
||||||
|
Loading…
Reference in New Issue
Block a user