Back up existing docker?


Recommended Posts

Docker on unRAID has 3 components

 

1. Config file. Small.

2. The container. Large but disposable since you can get iot form the online repo again (assuming you dont use EDGE)

3. The data files under appdata

 

BTRFS snapshots dont cover all 3 of these.

 

T

Link to comment

I've made a vary basic script to backup/restore containers a while ago, but only tested it twice, so be careful with it.

 

#!/bin/bash
D="$(dirname "$(readlink -f ${BASH_SOURCE[0]})")"

if [[ -n $1 ]]; then
  backup_path=$1
else
  exit 1
fi

if [[ -f ${backup_path}/restore.sh ]]; then
  echo Please choose an empty directory
  exit 0
fi

running_containers=$(docker ps -q)
if [[ -n $running_containers ]]; then
  docker stop ${running_containers}
fi

echo -e "#!/bin/bash\n" > ${backup_path}/restore.sh
for container in $(docker ps -a -q); do
  image_name=$(docker inspect -f "{{.Config.Image}}" ${container});
  image_id=$(docker inspect -f "{{.Image}}" ${container})
  container_name=$(docker inspect -f "{{.Name}}" ${container} | grep -Po '/\K.*')
  container_cmd=$(${D}/docker_cmd.php ${container_name})
  eval "docker save ${image_id} > ${backup_path}/${container_name}.tar";
  echo "docker load < ${backup_path}/${container_name}.tar" >> ${backup_path}/restore.sh;
  echo "docker tag ${image_id} ${image_name}" >> ${backup_path}/restore.sh;
  echo "$container_cmd" >> ${backup_path}/restore.sh;
done

chmod +x ${backup_path}/restore.sh

if [[ -n $running_containers ]]; then
  docker start ${running_containers}
fi

Link to comment

Thanks for the replies and info.

 

Since you responded, gfjardim, I am wanting to back up your btsync container before upgrading in case it upgrades to sync 2.0. Sync 2.0 is incompatible with the old 1.4 clients which all my other devices run.

 

Which version does it update to?

Link to comment

Thanks for the replies and info.

 

Since you responded, gfjardim, I am wanting to back up your btsync container before upgrading in case it upgrades to sync 2.0. Sync 2.0 is incompatible with the old 1.4 clients which all my other devices run.

 

Which version does it update to?

 

BTSync 2.0.82

Link to comment

Thanks for the replies and info.

 

Since you responded, gfjardim, I am wanting to back up your btsync container before upgrading in case it upgrades to sync 2.0. Sync 2.0 is incompatible with the old 1.4 clients which all my other devices run.

 

Which version does it update to?

 

And this is exactly why Dockers should be versioned and labeled and never auto update. They should always be exact snapshots in time. One never knows if an update will break everything or not. It's even worse with using developer branches of the application in question.

 

Link to comment

Thanks for the replies and info.

 

Since you responded, gfjardim, I am wanting to back up your btsync container before upgrading in case it upgrades to sync 2.0. Sync 2.0 is incompatible with the old 1.4 clients which all my other devices run.

 

Which version does it update to?

 

BTSync 2.0.82

 

Crap ok, thanks for the answer ;)  Save me the trouble of updating to find out it doesn't work with anything anymore.

Link to comment
  • 2 weeks later...

Docker on unRAID has 3 components

 

1. Config file. Small.

2. The container. Large but disposable since you can get iot form the online repo again (assuming you dont use EDGE)

3. The data files under appdata

 

BTRFS snapshots dont cover all 3 of these.

 

T

 

What is the location of the config file? I would like to make a backup of just appdata and my container configuration (The volume mappings, port mappings and other variables). I know where the appdata is, but where is the container configuration stored?

 

Link to comment

Docker on unRAID has 3 components

 

1. Config file. Small.

2. The container. Large but disposable since you can get iot form the online repo again (assuming you dont use EDGE)

3. The data files under appdata

 

BTRFS snapshots dont cover all 3 of these.

 

T

 

What is the location of the config file? I would like to make a backup of just appdata and my container configuration (The volume mappings, port mappings and other variables). I know where the appdata is, but where is the container configuration stored?

Not entirely sure what is meant by config file, since it is typically in a mapped volume, probably part of appdata for most dockers.

 

Perhaps he meant the template settings. Those are in /boot/config/plugins/dockerMan/templates-user

 

 

Link to comment

Docker on unRAID has 3 components

 

1. Config file. Small.

2. The container. Large but disposable since you can get iot form the online repo again (assuming you dont use EDGE)

3. The data files under appdata

 

BTRFS snapshots dont cover all 3 of these.

 

T

 

What is the location of the config file? I would like to make a backup of just appdata and my container configuration (The volume mappings, port mappings and other variables). I know where the appdata is, but where is the container configuration stored?

Not entirely sure what is meant by config file, since it is typically in a mapped volume, probably part of appdata for most dockers.

 

Perhaps he meant the template settings. Those are in /boot/config/plugins/dockerMan/templates-user

 

Great, thank you. The contents of the templates-user directory was exactly what I was looking for!

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.