Call Us! 1-800-383-5193
Call Us! 1-800-383-5193

Need Help?

Our experts will login to your server within 30 minutes to fix urgent issues.

We will keep your servers stable, secure and fast at all times for one fixed price.

Docker backup – Easy steps to backup and restore your containers

Docker backup – Easy steps to backup and restore your containers

Disasters cannot be predicted or prevented, but you can always quickly bounce back from them if you maintain adequate backup plans for your business.

That makes data backups indispensable for any online business. By reducing the time to restore a crashed business, backups help to save businesses and minimize the losses.

In Docker systems, containers are used to host applications or services. Today, we’ll see how to perform docker backup and restore functions for containers.

In Docker, data is categorized into two – docker images for creating containers and the container data. The container data may be stored in containers or data volumes.

Are your Docker containers insured?

CLICK HERE TO BACKUP YOUR DOCKER SYSTEM!

 

How to backup Docker containers

1. Before backing up a container, you need to identify its container ID. To know the container ID of a Docker instance, you can list the containers in that system.

The containers in a Docker machine can be listed using the command ‘docker ps’.

Docker backup - container list

Docker container list

 

2. To backup a container in this list, use the ‘docker commit’ command with the following syntax:

docker commit -p container-ID backup-name

The container ID can be obtained from the ‘docker ps’ list and the ‘backup-name’ can be chosen based on your backup policy.

Docker backup of container

Take backup of Docker container

 

This snippet shows the docker backup of container ‘679facd4ee38’ (WordPress container), being taken in the name ‘backup-01’.

3. The backup image of the container, also known as ‘snapshot’, would be created with the name ‘backup-01’ and will be listed in the ‘docker images’ list:

 

Docker backup of container image

Docker container backup image

 

This image of the container can be used to restore it on a later point and retrieve the state of the container to that moment this snapshot was taken.

4. It is not advisable to store the backups in the same Docker host machine as the container, as a hardware crash in it can tamper with the backups too.

So we usually convert these backup images to compressed formats such as ‘tar’ files and copy them over to an external server.

The ‘tar’ file for the backup image can be generated using the command:

docker save -o backup-name.tar backup-name

5. The tar file would be generated as shown, which can be copied over to external locations using ‘rsync’ or ‘scp’ tools.

Container backup image compressed file

Compressed tar file of container backup image

 

Tools such as docker-backup can also be configured to take docker backup of containers. At Bobcares, we use custom scripts to perform backups.

The docker backup scripts are compiled based on parameters such as backup frequency, storage location, priority and importance of the container, etc.

[ Running a Docker infrastructure doesn’t have to be hard, or costly. Get world class Docker management services at affordable pricing. ]


Looking for a stable Docker setup?

Talk to our Docker specialists today to know how we can keep your containers top notch!

CLICK HERE FOR EXPERT SOLUTIONS!

Docker
docker

12 Comments

  1. Very Helpful Article Keep up the good work. We need heroes like you in the world!

    Reply
    • True

      Reply
    • Thank you for your kind words, Sean 🙂

      Reply
  2. Awesome… fantastic… fabulous… great work…
    Thank you

    Reply
    • Thank you for your kind words, Priya 🙂

      Reply
  3. Hi Guys,

    How to backup a container with multiple “data-directory”?

    Thanks,

    // Jonas

    Reply
    • Jonas,

      It is also possible to backup data volumes. Please submit your details at https://bobcares.com/contact-us/ and our docker experts would configure the backups for you.

      Reply
  4. after running:
    docker run –rm –volumes-from new-container-name -v $(pwd):/backup ubuntu bash -c “cd /data-directory && tar xvf /backup/backup.tar –strip 1”

    I wasn’t able to run/start my container.

    I’m using jenkins as my base image.

    Reply
  5. Nice tutorial it’s been very useful !!!

    Reply
  6. Bob, you care, thank you for this.

    Reply
  7. Hi,
    i have an issue when we backup windows container volume it gives an error:
    PS C:\WINDOWS\system32> docker run –volumes-from volcontainer -v C:/backup myservercore tar -cvf c:/backup/backup.tar /c:/wincorevolume
    C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: container 83cddcbc17e458abbd2bf97ca788ad8d664e3a3b72bca3301f2a9a9abc12485a encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {“CommandLine”:”tar -cvf c:/backup/backup.tar /c:/wincorevolume”,”WorkingDirectory”:”C:\\”,”CreateStdInPipe”:true,”CreateStdOutPipe”:true,”CreateStdErrPipe”:true,”ConsoleSize”:[0,0]}.
    PS C:\WINDOWS\system32>
    Can u please give me suggestion how to backup volume

    Reply
  8. please share backup and restore volume container on windows

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Docker Support

Spend time on your business, not on your servers.

Managing a server is time consuming. Whether you are an expert or a newbie, that is time you could use to focus on your product or service. Leave your server management to us, and use that time to focus on the growth and success of your business.

TALK TO US Or click here to learn more.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF