Jump to content

simple backup script


rev.dennis
 Share

Recommended Posts

Here is the script

backup.sh

#!/bin/bash

#Created by Dennis Hosang 20130812
#day of week variable
DOW=$(date +%A)

#username variable
USERNAME="netadm1n"

#hostname variable
HOST=$(hostname|cut -f1 -d.)

#backup /home
sudo rsync --delete -azvv --exclude-from '/backups/home_exclude' --log-file=/backups/${DOW}/rsync_log /home/ 10.6.56.244:/backups/${HOST}/${DOW}/home/

#backup /boot
sudo rsync --delete -azvv --log-file=/backups/${DOW}/rsync_log /boot/ 10.6.56.244:/backups/${HOST}/${DOW}/boot/

#empty trash
rm -rf /home/${USERNAME}/.local/share/Trash/Files/*

#backup /root
sudo rsync -avz --delete --exclude-from '/backups/root_exclude' --log-file=/backups/${DOW}/rsync_log / 10.6.56.244:/backups/${HOST}/${DOW}/root/

#backup /home
#sudo rsync --delete -azvv --exclude-from '/backups/home_exclude' --log-file=/backups/${DOW}/rsync_log /home/ 10.6.56.244:/backups/${HOST}/${DOW}/home/

Just added it to my crontab

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user  command
#
37 14 * * * root sh /backups/backup.sh

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...