Jump to content

simple backup script


Recommended Posts

Here is the script



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

#username variable

#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/${HOST}/${DOW}/home/

#backup /boot
sudo rsync --delete -azvv --log-file=/backups/${DOW}/rsync_log /boot/${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 /${HOST}/${DOW}/root/

#backup /home
#sudo rsync --delete -azvv --exclude-from '/backups/home_exclude' --log-file=/backups/${DOW}/rsync_log /home/${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.


# 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.

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.


  • Create New...