• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to create File System Backup using Bash Script on Debian 12

  • 01:04 cat /etc/os-release
  • 01:13 mkdir -p /var/Backup/CompressedFilesystem
  • 01:45 mkdir -p /Backup/Filesystem1/{filesystem1.1,filesystem1.2,filesystem1.3}
  • 02:22 mkdir -p /Backup/Filesystem2/{filesystem2.1,filesystem2.2,filesystem2.3}
  • 03:12 ls -la /Backup/Filesystem2
  • 03:26 vim filesystembackup
  • 04:40 chmod +x filesystembackup
  • 04:51 ./filesystembackup
7885

To Create File System Backup Using Bash Script On Debian 12

Introduction:

A file system backup is a critical procedure for duplicating and safeguarding vital data from a computer or device to an alternative location. This practice guarantees that in the event the primary data is compromised, destroyed, or corrupted, it can be recovered from the backup. Backups are commonly saved on distinct devices such as external hard drives, cloud storage platforms, or network storage devices. They act as a protective measure against data loss stemming from hardware malfunctions, inadvertent deletions, cyber threats, or unforeseen events. Consistently conducting backups is imperative for safeguarding valuable data and maintaining seamless business operations.

Procedure:

Step 1: Check the OS version by using the following command.

root@linuxhelp:~# cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL=https://bugs.debian.org/

Step 2: Create Destination Directory for the Backup File by using the following command.

root@linuxhelp:~# mkdir -p /var/Backup/CompressedFilesystem

Step 3: Create Sample File System Directory by using the following command.

root@linuxhelp:~# mkdir -p /Backup/Filesystem1/{filesystem1.1,filesystem1.2,filesystem1.3}

Step 4: Again create another File System Directory by using the following command.

root@linuxhelp:~# mkdir -p /Backup/Filesystem2/{filesystem2.1,filesystem2.2,filesystem2.3}

Step 5: Check the Created Directory by using the following command.'

root@linuxhelp:~# ls -la /Backup/Filesystem2
total 20
drwxr-xr-x 5 root root 4096 Jul  7 11:16 .
drwxr-xr-x 5 root root 4096 Jul  7 11:16 ..
drwxr-xr-x 2 root root 4096 Jul  7 11:16 filesystem2.1
drwxr-xr-x 2 root root 4096 Jul  7 11:16 filesystem2.2
drwxr-xr-x 2 root root 4096 Jul  7 11:16 filesystem2.3

Step 6: Create script to take backup automatically by using the following command.

root@linuxhelp:~# vim filesystembackup
#!/bin/bash
# Destination folder path specify using variable
Backup_Destination="/var/Backup/CompressedFilesystem"
# Specify File System with the path using variable
File_System="/Backup/Filesystem1 /Backup/Filesystem2"
# Get date for name of compressed file
Date=$(date +%F)
# Get Hostname for name of compressed file
Hostname=$(hostname -s)
# Specify the structure of compressed file with path using variable
Compressed_File=$Backup_Destination/$Hostname-$Date.tar.gz
# Display Information of Backup Process
echo "Backup Started From $File_System To $Compressed_File"
echo 
echo "Day $(date)"
echo 
# Take Backup using tar command 
tar czf $Compressed_File $File_System
# Display the Information about the Backup Completion
echo "Backup Completed"
echo 
echo "$(date)"
echo
# Display the Backup file with the size in a user readable format
echo 
ls -lh $Backup_Destination
echo

Step 7: Make the executable permission to the script file by using following ocmmand.

root@linuxhelp:~# chmod +x filesystembackup

Step 8: Run the script file by using following command.

root@linuxhelp:~# ./filesystembackup 
Backup Started From /Backup/Filesystem1 /Backup/Filesystem2 To /var/Backup/CompressedFilesystem/linuxhelp-2024-07-07.tar.gz
Day Sunday 07 July 2024 11:33:33 AM IST
tar: Removing leading `/' from member names
Backup Completed
Sunday 07 July 2024 11:33:33 AM IST
total 4.0K
-rw-r--r-- 1 root root 200 Jul  7 11:33 linuxhelp-2024-07-07.tar.gz

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to create File System Backup using Bash script on Debian 12. Your feedback is much welcome.

Tags:
gabriel
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

Why do I need to backup my files?

A

Backups are essential to protect against data loss from hardware failures, accidental deletion, malware attacks, and natural disasters. They ensure you can recover important files and maintain business continuity.

Q

What is the best backup method?

A

The best backup method depends on your needs. Common methods include full backups (copying all data), incremental backups (only new or changed files since the last backup), and differential backups (copies files changed since the last full backup). A combination of these methods often provides robust protection

Q

Where should I store my backups?

A

It's recommended to store backups in multiple locations. Options include external hard drives, network-attached storage (NAS), cloud storage services (like Google Drive, Dropbox, or AWS S3), or offsite backups (physically separate from your primary location to protect against disasters affecting the primary site).

Q

How often should I perform backups?

A

The frequency of backups depends on how often your data changes and how critical it is. For most users, daily or weekly backups are sufficient. For businesses dealing with critical data, backups may be performed more frequently, even multiple times a day.

Q

How do I ensure my backups are secure?

A

To ensure backup security, consider encryption for data both in transit (during backup) and at rest (stored backups). Use strong passwords and access controls for backup storage locations. Regularly test and verify backups to ensure they can be successfully restored when needed.

Related Tutorials in How to create File System Backup using Bash Script on Debian 12

Related Tutorials in How to create File System Backup using Bash Script on Debian 12

How to Install Mondo Rescue Disaster Recovery Tool in Linux
How to Install Mondo Rescue Disaster Recovery Tool in Linux
Jun 9, 2016
How to install Gparted on Debian 9.0
How to install Gparted on Debian 9.0
Sep 13, 2017
Installation SSL Certificate on Ubuntu/Linuxmint/Debian to Secure Apache
Installation SSL Certificate on Ubuntu/Linuxmint/Debian to Secure Apache
Sep 19, 2018
How to install and update OpenSSL on Debian 11.3
How to install and update OpenSSL on Debian 11.3
Oct 21, 2022
How to Setup Backup Server Using Bacula And Webmin in CentOS
How to Setup Backup Server Using Bacula And Webmin in CentOS
Jul 20, 2016
How to install qBittorrent on Debian 9.0
How to install qBittorrent on Debian 9.0
Sep 8, 2017
How to Install FileZilla in Debian
How to Install FileZilla in Debian
Nov 29, 2016
How to install Nmap on Debian 9.0
How to install Nmap on Debian 9.0
Sep 9, 2017

Related Forums in How to create File System Backup using Bash Script on Debian 12

Related Forums in How to create File System Backup using Bash Script on Debian 12

Backup
joshwariddin class=
Elastix backup file location
Jan 29, 2018
MariaDB
ryan class=
E: Unable to locate package mariadb-server
Sep 18, 2017
Linux
AadrikaAnshu class=
How to add timestamps to history On Any Linux Machine
Jun 18, 2019
Ubuntu
mason class=
Backup files with rsync: error 23
Feb 25, 2021
vim
jacob class=
Change true vi-compatible editor from Debian Vim-compatible
Nov 8, 2021
debian
anandaamatya class=
RedNotebook on Debian buster
Jun 30, 2020
Bash-scripting
aristosv class=
Bash script filtering output issue
Jun 4, 2019
Shell Script
symonds class=
Sort only unique words inside a file
Apr 6, 2018

Related News in How to create File System Backup using Bash Script on Debian 12

Related News in How to create File System Backup using Bash Script on Debian 12

Debian IceDove kicks the bucket after Thunderbird revisits Debian Repositories
Debian IceDove kicks the bucket after Thunderbird revisits Debian Repositories
Feb 28, 2017
Mass update of Jessie - A better alternative to new version?
Mass update of Jessie - A better alternative to new version?
May 8, 2017
Debian 9.2 ‘Stretch’ OS is here, download distro now
Debian 9.2 ‘Stretch’ OS is here, download distro now
Oct 9, 2017
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Elijah ?
Remote Desktop Connection Has Stopped Working

When accessing my remote machine server using remote desktop on a windows machine I am getting this error

forum (1)

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.