Question

how to put dokku data into block storage?

By default Dokku have to directory /home/dokku and /var/lib/dokku/. How can i store it in block storage? Purpose in future if upgrade process of the host machine fail i can just unattached block storage, start new droplet, install dokku, mount block storage and all done…


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

@chengjk

You can read the guide below to setup your block storage:

https://www.digitalocean.com/community/tutorials/how-to-use-block-storage-on-digitalocean#preparing-volumes-for-use-in-linux

From there, you have a few options: symlink directories or mount them. But before you do anything below, make sure you backup backup backup. Once you rm -rf a directory, it’s gone and it’s not coming back.

1). Symlink Directories

Since /home/dokku is the current home directory, you would simply create a new directory on the block storage device:

mkdir -p /path/to/block/device/dokku

Copy current data from /home/dokku to the new location:

cp -R /home/dokku/* /path/to/block/storage/dokku

NOTE: Before the next step, make sure all data was successfully copied to the new directory!

Now delete the current directory and create a symlink to the new one:

sudo rm -rf /home/dokku
sudo ln -s /home/dokku /path/to/block/storage/dokku

2). Mount Directories

mkdir -p /path/to/block/device/dokku

Copy current data from /home/dokku to the new location:

cp -R /home/dokku/* /path/to/block/storage/dokku

NOTE: Before the next step, make sure all data was successfully copied to the new directory!

Now delete the current directory and mount to the new one:

sudo rm -rf /home/dokku
sudo mount --bind /home/dokku /path/to/block/storage/dokku

Now this is NOT permanent, so you need to modify fstab and place an entry in there as well:

nano /etc/fstab

and paste in:

/home/dokku   /path/to/block/storage/dokku   none    bind

Instead of copying files is better to move the folder

mv /home/dokku /path/to/block/storage/

When it says “Now delete the current directory and mount to the new one:” the command shuld be:

sudo rm -rf /home/dokku
mkdir /home/dokku
sudo mount --bind /path/to/block/storage/dokku /home/dokku

and /etc/fstab should be

/path/to/block/storage/dokku  /home/dokku   none    bind

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel