Back to Blog

ArangoDB on AWS: Automate Install, S3 Backup & Restore with Systemd

DatabaseDevOpsArangoDBAWSShellScriptBackupS3Systemd
ArangoDB automated backup and restore on AWS EC2 with S3 storage

Introduction

ArangoDB is a native multi-model database, documents, graphs, and key/value, accessible through a single query language (AQL). Running it on AWS EC2 requires disciplined automation: the database process, configuration management, daily backups to S3, and a tested restore path. This guide provides production-ready shell scripts for all four concerns.

The scripts target ArangoDB 3.6.5-1 on Ubuntu 18.04. For ArangoDB 3.12+ on Ubuntu 22.04, update the repository URL and package version in Step 1. All other scripts remain unchanged.

Installing the Latest Version of ArangoDB on Ubuntu 18.04

Visit the ArangoDB website to download the latest version of the database. As of this guide, the current version is 3.6.5-1. Below is a script to install and configure ArangoDB on an AWS EC2 server.

Important Precautions

Ensure that you stop the ArangoDB service and switch your application to maintenance mode before proceeding.

bash
#!/bin/bash sudo systemctl stop arangodb3.service sudo cp -r /etc/arangodb3/ ~/arango-config-backup curl -OL https://download.arangodb.com/arangodb36/DEBIAN/Release.key sudo apt-key add - < Release.key echo 'deb https://download.arangodb.com/arangodb36/DEBIAN/ /' | sudo tee /etc/apt/sources.list.d/arangodb.list sudo apt-get update sudo apt-get install arangodb3=3.6.5-1 sudo sed -i "s+endpoint = tcp://127.0.0.1:8529+endpoint = tcp://0.0.0.0:8529+g" /etc/arangodb3/arangod.conf sudo systemctl enable arangodb3.service sudo systemctl start arangodb3.service sudo systemctl status arangodb3.service sudo sysctl -w "vm.max_map_count=1024000"

Backup and Upload ArangoDB to Amazon S3

This script handles the backup of ArangoDB and its upload to Amazon S3 storage.

bash
#!/bin/sh NOWDATE=$(date +%Y-%m-%d) DIRNAME="Your directory name" BUCKETNAME="Your bucket name in S3" DATABASENAME="Your database name" mkdir -p "/home/ubuntu/backup/$DIRNAME" arangodump --server.endpoint tcp://127.0.0.1:8529 --server.username root --server.password 'yourpassword' --server.database $DATABASENAME --output-directory "/home/ubuntu/backup/$DIRNAME/" --compress-output --overwrite tar -czvf /home/ubuntu/backup/$NOWDATE-$DATABASENAME-backup.tar.gz -C /home/ubuntu/backup/$DIRNAME . aws s3 cp /home/ubuntu/backup/$NOWDATE-$DATABASENAME-backup.tar.gz s3://$BUCKETNAME/dbbackup/ aws s3 rm s3://$BUCKETNAME/dbbackup/$LASTDATE-$DATABASENAME-backup.tar.gz rm -rf /home/ubuntu/backup/$NOWDATE-$DATABASENAME-backup.tar.gz rm -rf /home/ubuntu/backup/$DIRNAME/*

Restore ArangoDB from Amazon S3

The following script details the procedure to restore ArangoDB from a backup stored on Amazon S3.

bash
#!/bin/sh DIRNAME="Your directory name" BUCKETNAME="Your bucket name in S3" DATABASENAME="Your database name" read -p "Please enter file date (YYYY-MM-DD):" FILE_NAME aws s3 cp s3://$BUCKETNAME/dbbackup/$FILE_NAME-$DATABASENAME-backup.tar.gz /home/ubuntu/backup/ tar -xzvf /home/ubuntu/backup/$FILE_NAME-$DATABASENAME-backup.tar.gz -C /home/ubuntu/backup/$DIRNAME arangorestore --server.endpoint tcp://127.0.0.1:8529 --server.username root --server.password 'yourpassword' --server.database $DATABASENAME --input-directory "/home/ubuntu/backup/$DIRNAME" --create-database rm -rf /home/ubuntu/backup/$FILE_NAME-$DATABASENAME-backup.tar.gz rm -rf /home/ubuntu/backup/$DIRNAME/*

Automating Backups with Systemd Services

Automate your backup tasks with systemd services for better management and reliability.

  1. Navigate to /etc/systemd/system and create backup.service and backup.timer.
  2. Configure the backup service file to run

the backup script. 3. Set the timer to execute the backup script at a specified time.

bash
[Unit] Description=Schedule ArangoDB backup service [Timer] OnCalendar=*-*-* 02:30:00 Unit=backup.service [Install] WantedBy=multi-user.target
bash
[Unit] Description=Run ArangoDB backup script [Service] ExecStart=/bin/bash /home/ubuntu/backup/backup.sh

After setting up these files, manage the services as follows:

sudo systemctl daemon-reload
sudo systemctl start backup.timer
sudo systemctl status backup.timer

With these steps, you will have a fully automated backup system on your server.

X / Twitter
LinkedIn
Facebook
WhatsApp
Telegram

About Pooya Golchian

Common questions about Pooya's work, AI services, and how to start a project together.

Get practical AI and engineering playbooks

Weekly field notes on private AI, automation, and high-performance Next.js builds. Each edition is concise, implementation-ready, and tested in production work.

Open full subscription page

Get the latest insights on AI and full-stack development.