Showing posts with label Bash. Show all posts
Showing posts with label Bash. Show all posts

Friday, January 5, 2018

Tarball an entire Linux system

#!/bin/bash
#Version: 1.0
#Description:  Checks for a destination mount directory.  Mounts it if it does not exist, the backs up the server to the mount directory.

mountdir="<mount directory>"
servername="<servername>"
exclusions="--exclude=/mnt --exclude=/proc --exclude=/lost+found --exclude=/tmp --exclude=/media --exclude=/sys --exclude=/dev --exclude=/run --exclude=/var/cache"

if [ -d $mountdir ]; then
     cd $mountdir
     tar -zcpf $servername-full-backup-`date '+%d-%B-%Y'`.tar.gz / $exclusions
else
     sudo mount -t cifs -o username=moatisuser,password=moatisuser,rw \\\\fw24\\ata_1 /mnt/fw24
     cd $mountdir
     tar -zcpf $servername-full-backup-`date '+%d-%B-%Y'`.tar.gz / $exclusions
fi

Tarball an entire Linux system

#!/bin/bash
#Version: 1.0
#Description:  Checks for a destination mount directory.  Mounts it if it does not exist, the backs up the server to the mount directory.

mountdir="<mount directory>"
servername="<servername>"
exclusions="--exclude=/mnt --exclude=/proc --exclude=/lost+found --exclude=/tmp --exclude=/media --exclude=/sys --exclude=/dev --exclude=/run --exclude=/var/cache"

if [ -d $mountdir ]; then
     cd $mountdir
     tar -zcpf $servername-full-backup-`date '+%d-%B-%Y'`.tar.gz / $exclusions
else
     sudo mount -t cifs -o username=moatisuser,password=moatisuser,rw \\\\fw24\\ata_1 /mnt/fw24
     cd $mountdir
     tar -zcpf $servername-full-backup-`date '+%d-%B-%Y'`.tar.gz / $exclusions
fi

Tarball an entire Linux system

#!/bin/bash
#Version: 1.0
#Description:  Checks for a destination mount directory.  Mounts it if it does not exist, the backs up the server to the mount directory.

mountdir="<mount directory>"
servername="<servername>"
exclusions="--exclude=/mnt --exclude=/proc --exclude=/lost+found --exclude=/tmp --exclude=/media --exclude=/sys --exclude=/dev --exclude=/run --exclude=/var/cache"

if [ -d $mountdir ]; then
     cd $mountdir
     tar -zcpf $servername-full-backup-`date '+%d-%B-%Y'`.tar.gz / $exclusions
else
     sudo mount -t cifs -o username=moatisuser,password=moatisuser,rw \\\\fw24\\ata_1 /mnt/fw24
     cd $mountdir
     tar -zcpf $servername-full-backup-`date '+%d-%B-%Y'`.tar.gz / $exclusions
fi

Tarball an entire Linux system

#!/bin/bash
#Version: 1.0
#Description:  Checks for a destination mount directory.  Mounts it if it does not exist, the backs up the server to the mount directory.

mountdir="<mount directory>"
servername="<servername>"
exclusions="--exclude=/mnt --exclude=/proc --exclude=/lost+found --exclude=/tmp --exclude=/media --exclude=/sys --exclude=/dev --exclude=/run --exclude=/var/cache"

if [ -d $mountdir ]; then
     cd $mountdir
     tar -zcpf $servername-full-backup-`date '+%d-%B-%Y'`.tar.gz / $exclusions
else
     sudo mount -t cifs -o username=moatisuser,password=moatisuser,rw \\\\fw24\\ata_1 /mnt/fw24
     cd $mountdir
     tar -zcpf $servername-full-backup-`date '+%d-%B-%Y'`.tar.gz / $exclusions
fi

Tuesday, January 2, 2018

Tarball an entire Linux system

#!/bin/bash
#Version: 1.0
#Description:  Checks for a destination mount directory.  Mounts it if it does not exist, the backs up the server to the mount directory.

mountdir="<mount directory>"
servername="<servername>"
exclusions="--exclude=/mnt --exclude=/proc --exclude=/lost+found --exclude=/tmp --exclude=/media --exclude=/sys --exclude=/dev --exclude=/run --exclude=/var/cache"

if [ -d $mountdir ]; then
     cd $mountdir
     tar -zcpf $servername-full-backup-`date '+%d-%B-%Y'`.tar.gz / $exclusions
else
     sudo mount -t cifs -o username=moatisuser,password=moatisuser,rw \\\\fw24\\ata_1 /mnt/fw24
     cd $mountdir
     tar -zcpf $servername-full-backup-`date '+%d-%B-%Y'`.tar.gz / $exclusions
fi