Home WebServer PanelDirectAdmin How to back up DirectAdmin with command line

How to back up DirectAdmin with command line

by Thạch Phạm
Published: Last Updated on
A+A-
Reset

In this article, AZDIGI will show you to back up DirectAdmin with the command line quickly, simply and easily. If you are not familiar with command line operations, you can refer to the article How to back up and restore DirectAdmin through the interface.

By default, the DirectAdmin interface has built-in backup and restore features. However, for some reason, like your server is down, your DirectAdmin license has expired or you still prefer using commands over interfaces, this is the tutorial for you.

First, we need to access the root user via console or SSH (where SSH is possible). If you don’t know how to SSH into your VPS/Server, you can refer to the following tutorial:

After logging in as root, we will have 2 options to backup: full backup or single-user backup. I will guide each case below fully for you to understand better.

Backup DirectAdmin with command line for all users

To backup all users, we use the following command:

AZDIGI Tutorial
echo "action=backup&append%5Fto%5Fpath=nothing&database%5Fdata%5Faware=yes&email%5Fdata%5Faware=yes&local%5Fpath=%2Fhome%2Fadmin%2Fadmin%5Fbackups&owner=admin&type=admin&value=multiple&when=now&where=local&who=all" >> /usr/local/directadmin/data/task.queue
    

Currently, my VPS has 1 user and an admin, so after running the above command and waiting for a few minutes, there are two backup files in the /home/admin/admin_backups directory, as shown below:

Screen Shot 2020 07 19 at 6.38.49 PM

Before running the command, there is no backup file.

Screen Shot 2020 07 19 at 6.53.03 PM

After running the backup command, we have 2 backup files corresponding to the existing users. If you have more users, it will take more time and the files after the backup will be available one by one. If your space is insufficient to fully backup all users, the system will automatically stop when it’s full.

Case 2: Backup DirectAdmin with command line for a single user

To backup for single user, use the following command:

AZDIGI Tutorial
echo "action=backup&append%5Fto%5Fpath=nothing&database%5Fdata%5Faware=yes&email%5Fdata%5Faware=yes&local%5Fpath=%2Fhome%2Fadmin%2Fadmin%5Fbackups&owner=admin&select%30=testuser&type=admin&value=multiple&when=now&where=local" >> /usr/local/directadmin/data/task.queue
    

Replace testuser with the name of the user you want to restore.

For example, I have a user named demo2, I will use the following command to backup this user.

AZDIGI Tutorial
echo "action=backup&append%5Fto%5Fpath=nothing&database%5Fdata%5Faware=yes&email%5Fdata%5Faware=yes&local%5Fpath=%2Fhome%2Fadmin%2Fadmin%5Fbackups&owner=admin&select%30=demo2&type=admin&value=multiple&when=now&where=local" >> /usr/local/directadmin/data/task.queue
    

After running the command, we wait a moment to see the full backup file of this user at /home/admin/admin_backup/:

backup DirectAdmin with command line restore

In case you want to restore this demo2 user, use the following command:

AZDIGI Tutorial
echo "action=restore&ip%5Fchoice=file&local%5Fpath=%2Fhome%2Fadmin%2Fadmin%5Fbackups&owner=admin&select%30=user%2Eadmin%2Edemo2%2Etar%2Egz&type=admin&value=multiple&when=now&where=local" >> /usr/local/directadmin/data/task.queue
    

Remember to change demo2 to your user. If your backup file has a different name, substitute the names holding %2E (Hex value, equivalent for dot). You can also use demo2%2Etar%2Egz format and it will work fine.

This restore command will use the same IP in the configuration of this backup file. No problem if this backup is created on this VPS/Server itself. But if this is a backup file coming from another VPS/Server, you need to add the option ip_choice=select&ip=1.2.3.4 in there 1.2.3.4 you change to your VPS/Server IP

So have completed the DirectAdmin backup steps with the command line for a single user.

Summary

Thus, we have completed the DirectAdmin backup steps with the command line as well as restoring a user using the command line. Hy vọng bài viết này sẽ giúp ích cho các bạn trong nhiều trường hợp.

Reference articles:

Đánh giá

Tham gia nhóm hỗ trợ Server - Hosting

Tham gia nhóm Hỗ trợ Server - Hosting & WordPress để cùng nhau hỏi đáp và hỗ trợ các vấn đề về WordPress, tối ưu máy chủ/server.

Tham gia ngay

Bài viết cùng chuyên mục

AZDIGI – Không chỉ là đơn vị hàng đầu trong lĩnh vực Web Hosting và Máy chủ, chúng tôi mong muốn mang lại những kiến thức bổ ích nhất và luôn cập nhật thường xuyên cho cộng đồng người đam mê thiết kế website, công nghệ,…

Vui lòng không sao chép nội dung nếu chưa xin phép. Designed and Developed by PenciDesign