Home WebServer PanelDirectAdmin Add time to backup filenames on DirectAdmin

Add time to backup filenames on DirectAdmin

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

In this tutorial, AZDIGI will show you how to add time to the backup file name on DirectAdmin.

I. Introduction

By default, when using the Admin Backup/Transfer feature on the DirectAdmin interface with the Admin account, the files after the backup will have the following name:

AZDIGI Tutorial
user.reseller.username.tar.gz
    

In there, the username will correspond to the name of that user and the reseller will be the owner of that user.

For example, below is a User belonging to reseller adminbao that I just created a backup. As you can see, the backup filename doesn’t have a date when you created the backup, and when you continue to backup for this user, this file will be overwritten by the new backup file.

how-to-add-time-to-backup-filenames-on-directadmin

AZDIGI will show you how to add time to the DirectAdmin backup filename to fix this situation. It is convenient to manage and restore from many different backup versions.

II. Add time to backup filenames on DirectAdmin

To add time to the backup filename on DirectAdmin, we follow these 3 steps.

Step 1: SSH into your DirectAdmin system

To add time to the backup filename on DirectAdmin, we first need to SSH or access your VPS/server with root privileges. If you don’t know how to SSH into your VPS/Server, you can refer to the following tutorial:

After successfully SSH, we continue with step 2 to create a script that supports adding time to the backup filename on DirectAdmin.

Step 2: Create a script that adds time to the backup filename on DirectAdmin

To create this script and save it in the correct location, use the following command:

AZDIGI Tutorial
vi /usr/local/directadmin/scripts/custom/user_backup_post.sh
    

Next, please fill in the content into this file:

AZDIGI Tutorial
#!/bin/sh

#set this as needed
RESELLER=admin

BACKUP_PATH=`echo $file | cut -d/ -f1,2,3,4`
REQUIRED_PATH=/home/$RESELLER/admin_backups

if [ "$BACKUP_PATH" = "$REQUIRED_PATH" ]; then
   if [ "`echo $file | cut -d. -f4,5`" = "tar.gz" ]; then
       NEW_FILE=`echo $file | cut -d. -f1,2,3`.`date +%F-%Hh-%Mp`.tar.gz
       if [ -s "$file" ] && [ ! -e "$NEW_FILE" ]; then
           mv $file $NEW_FILE
       fi
   fi
fi
exit 0;
    

Then save and run the following command to assign permissions to the newly created file.

AZDIGI Tutorial
chmod 755 /usr/local/directadmin/scripts/custom/user_backup_post.sh
    

Now let’s go to step 3 to create a backup for a user and recheck the filename.

Step 3: Backup a User on DirectAdmin

If you want to back up users with the command,

you can refer to the following article:

If you backup users with the DirectAdmin interface, the location you save must is file /home/admin/admin_backups.

how-to-add-time-to-backup-filenames-on-directadmin

Below is the file I just created for a new backup.

how-to-add-time-to-backup-filenames-on-directadmin

As you can see, the backup filename also shows the date, time, and minutes. You should combine the following articles with being able to back up to Google Drive to make your backups safer.

III. Summary

With just 3 steps, you can add time to the DirectAdmin backup filename, so you can easily restore data from multiple backups at different time points.

Hope this article will be of help to you. Wishing you success!

See more useful articles about DirectAdmin at the following link:

If you need assistance, you can contact support in the ways below:

Đá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