Go Home Project Directory Back to VM-Backit

[VM-Backit] Simple System Backup Utility - Script Previews

VM-Backit is simple and easy to use command line based system utility to be used for backing up your preferred (configured) directories and databases followed by a clean packaging into dated archives contained within a /backup directory.
Fork VM-Backit on GitHub

[VM-Backit System Backup - prep script]

#!/bin/bash
#
# [VM-Backit System Backup - prep script]
#
# GitHub:   https://github.com/JMSDOnline/vm-backit
# Author:   Jason Matthews
# URL:      https://jmsolodesigns.com/code-projects/vm-backit/system-backup-utility
#
#start
#-----------------------------------------------------------------------

#Script Console Colors
black=$(tput setaf 0); red=$(tput setaf 1); green=$(tput setaf 2); on_green=$(tput setab 2); bold=$(tput bold); standout=$(tput smso); normal=$(tput sgr0); underline=$(tput smul); sub_title=${bold}${yellow}; repo_title=${black}${on_green};

PROGNAME="VM-Backit"
VERSION="1.0.1"

cat <<<>EOF
  $PROGNAME ver. $VERSION

  The primary use of this script is for running 
  manual backups on user specified directories 
  and databases. 

  This script will also package your directories
  and databases into one archive and perform a 
  backup cleanup.

  Please review the following scripts and make the 
  necessary changes to ensure successful backups.

  ${underline}Directory Backup:${normal}
  /root/vm-backit-util/directory-backup.sh

  ${underline}Database Backup:${normal}
  /root/vm-backit-util/database-backup.sh
EOF

# Create vm-backit & backup directory strucutre
mkdir -p ~/vm-backit-util /backup/{directories,databases}
cd ~/vm-backit-util

# Download the needed scripts for VM-Backit
curl -LO https://raw.githubusercontent.com/JMSDOnline/vm-backit/master/directory-backup.sh >/dev/null 2>&1;
curl -LO https://raw.githubusercontent.com/JMSDOnline/vm-backit/master/database-backup.sh >/dev/null 2>&1;
curl -LO https://raw.githubusercontent.com/JMSDOnline/vm-backit/master/package-backups.sh >/dev/null 2>&1;
curl -LO https://raw.githubusercontent.com/JMSDOnline/vm-backit/master/backup-cleanup.sh >/dev/null 2>&1;

# Convert all shell scripts to executable
chmod +x *.sh
cd

# Download VM-Backit System Backup Executable
curl -LO https://raw.githubusercontent.com/JMSDOnline/vm-backit/master/vm-backit >/dev/null 2>&1;
chmod +x vm-backit
mv vm-backit /usr/local/bin

###############################################################################
echo
echo
echo "VM-Backit is now installed. Please make the needed changes in";
echo "the required files.";
echo
echo "Once changes are perform, you can run the script by simply typing:";
echo "${bold}${green}vm-backit${normal}";
echo
echo
###############################################################################

#-----------------------------------------------------------------------
#end
[VM-Backit System Backup - directory backup]

#!/bin/bash
#
# [VM-Backit System Backup - directory backup]
#
# GitHub:   https://github.com/JMSDOnline/vm-backit
# Author:   Jason Matthews
# URL:      https://jmsolodesigns.com/code-projects/vm-backit/system-backup-utility
#
#start
#-----------------------------------------------------------------------

green=$(tput setaf 2);
magenta=$(tput setaf 5);
normal=$(tput sgr0);
OK=$(echo -e "[ ${green}DONE${normal} ]")
OUTTO="/root/vm-backit.log"

# verify directory structure exists prior to running this job
# if you are using the standalone, modify this according to
# your current and/or future directory structures preferred paths
DIRBfiles="/srv/www /etc /root";

# Where to backup to.
DIRDest="/backup/directories/";

# Create archive filename.
DIRDay=$(date +%b-%d-%y);
DIRHostname=$(hostname -s);
DIRAfile="$DIRHostname-$DIRDay.tgz";

# Print start status message.
  echo -n "Backing up ${magenta}$DIRBfiles${normal} to ${magenta}$DIRDest$DIRAfile${normal} ... ";
  date >>"${OUTTO}" 2>&1;
  echo >>"${OUTTO}" 2>&1;

# Backup the files using tar.
  tar -cpzf $DIRDest$DIRAfile $DIRBfiles >>"${OUTTO}" 2>&1 &&
    echo -n "${OK}"
    echo

# This gets pushed to the vs-backup command
# Print end status message.
  echo >>"${OUTTO}" 2>&1;
  echo "Backup finished" >>"${OUTTO}" 2>&1;
  date >>"${OUTTO}" 2>&1;

# Long listing of files in $dest to check file sizes.
  ls -lh $DIRDest >>"${OUTTO}" 2>&1;
#-----------------------------------------------------------------------
#end

# Example Schedule
# Backup Website Files Daily @ 12:45 AM
# 45 00 * * * root /etc/cron.daily/backup-website-files