Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
# Run rsnapshot backups
# Before the actual backup rotate less frequent sets before the more
# frequent sets. Oldest weekly becomes newest monthly, oldest daily becomes
# newest weekly, etc. This has the addition benefit of not having to worry
# how long the backup will take. Testing shows 15 minutes to be enough
# time between rotations
# Run monthly on first of month at 0015:
15 1 1 * * /usr/bin/rsnapshot monthly
# Run weekly on first day (Monday) of week at 0130:
30 1 * * 1 /usr/bin/rsnapshot weekly
# The sync_first option is set, run sync; if no fatal error run rotation
# Run daily every day at 0145:
45 1 * * * /usr/bin/rsnapshot sync; [ $? -ne 1 ] && /usr/bin/rsnapshot daily
# Run hourly every 8 hours starting at 0200:
#0 */8 * * * /usr/bin/rsnapshot sync; [ $? -ne 1 ] && /usr/bin/rsnapshot hourly
#!/bin/bash
#
###########################################################
# Created by lleb January 11, 2015
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 or version 3 of the
# license, at your option.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#############################################################
#
#
#############################################################
#
# Backup program for laptops to Linux server using
# rsync -aviS
#
#############################################################
# Veriables
RUSER=user
RHOST=server_IP
WHO=`whoami`
DOW=`date +%A`
RDIR=/path/to/Backup # New server path <1/15/2016>
HOMEDIR="$HOME"
dtstamp="`date +%Y-%m-%d-%H:%M `"
log=${HOMEDIR}/logs/${dtstamp}-rsync.log
###############################################################
### Check for a logs directory, if not found create one
###############################################################
[ ! -d "${HOMEDIR}/logs" ] && mkdir -p ${HOMEDIR}/logs >> /dev/null 2>&1
###############################################################
#
# Rsync preserving permissions
#
###############################################################
rsync -aviS --exclude-from=${HOMEDIR}/excludes.txt ${HOMEDIR}/ ${RUSER}@${RHOST}:${RDIR}/${WHO}/${DOW}/ >> ${log} 2>&1
### Cleaning up log files
###############################
find ${HOMEDIR}/logs/*.log -mtime +30 -exec rm '{}' \;
exit
Put that script in your users cron after chmod +x and you should be good. This uses an exclude file that can block directories as well as types and specific files you dont want/need to backup.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.