Backups using rsync


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Backups using rsync
# 1  
Old 03-27-2013
Backups using rsync

Hello all,

I'm using nas4free as a SAN and am having troubles getting a backup of it's data to work properly. I've posted in the nas4free forums, but haven't received much help.

Here is the code I'm using:

Code:
#!/bin/sh
{
#########################################################################################
# File:    casedatabackup.sh
# Author:    Daryl Patino
# Date:   03-18-2013
# Purpose:   Daily incremental backups and weekly archive of backups using rsync
#
# 
# Important Usage Notes:
# -cp this file with a different name to retain this file as a template
# -edit logfilename located in BODY variable and end of script to match share
# -view existing scripts for examples
# -end all directory variables with /
# -must run the following command on the file "chmod u+x /path/file"
#########################################################################################


#########################################################################################
# Constant variables, do not change
#########################################################################################

DAY=$(date +%A)
DATE=$(date +%m_%d_%y)
PRINTF=/usr/bin/printf
MSMTP=/usr/local/bin/msmtp
MSMTPCONF=/var/etc/msmtp.conf


#########################################################################################
# Dynamic variables, changeable
#########################################################################################

# Mail settings
FROM="nas4free@usinfosec.com"
TO="helpdesk@usinfosec.com"
MDIR="CaseData"
SUBJECT="$MDIR Backup Report"
BODY="$(cat /mnt/support/logs/casedata.log)"

# Sync settings
RSOURCE="/mnt/POOL/CaseData/"
RDEST="/mnt/syl-s-012/Backups/CaseData/Daily/"
ASOURCE=$RDEST
ADEST="/mnt/syl-s-012/Backups/CaseData/Weekly/"


#########################################################################################
# Backup operations
#########################################################################################

# Daily file sync
rsync -a --stats $RSOURCE $RDEST

# Weekly archive and follow up sync to remove deleted files
if [ $day = "Sunday" ]; then
   tar -zcf $ADEST$DATE.tar.gz $ASOURCE
   rsync -a --delete --stats $RSOURCE $RDEST
   find $ADEST -mtime +14 -exec rm {} \;
fi

# Sends email of log file
$PRINTF "From:$FROM\nTo:$TO\nSubject:$SUBJECT\n\n$BODY" | $MSMTP --file=$MSMTPCONF -t

} > /mnt/support/logs/casedata.log

It is scheduled to run as a cron once per day via the nas4free gui. The script runs, and the daily rsync works, but the log file is empty and the weekly commands (in the if statement) do not seem to be working. When I run the tar individually, I get the following:

Quote:
syl-s-030:~# tar -zcfv /mnt/syl-s-012/Backups/CaseData/Weekly/date.tar.gz /mnt/syl-s-012/Backups/CaseData/Daily/
tar: Removing leading '/' from member names

/: write failed, filesystem is full
tar: Write error
I know that the embedded nas4free doesn't have room to install any additional applications, but the source and destination are mounted shares.

So my questions are this.

Does tar use some kind of temp directory that is local? If so, can it be changed?

My logging syntax might be incorrect. If so, how can I create a log of the scripts output that can be emailed?
# 2  
Old 03-27-2013
If I am going to delete stuff after archiving it into a tar (and I prefer a zip so you have random access to every file, and compression tailored to every file), youshould have marker times or files with times so the only files you remove are unchanged since a second before the tar/zip. Also, I like to get the names out of a tar (or unzip) listing, in case there is a problem with the tar (or zip) file, like running out of space or being signalled. Also, check $? one way or another so you do not proceed when things went awry!

There are tools like jdbc from hxtt that can SQL query wild card lists of files in trees, including zip files as if dirs and their internal trees in mid-tree, so the archived data is still a peer to raw files.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Rsync Error: rsync: link_stat failed: No such file or directory (2)

I wish to copy all the files & folder under /web/Transfer_Files/data/ on mymac1 (Linux) to remote server mybank.intra.com (Solaris 10) /tmp/ location I am using Ansible tool synchronize module which triggers the unix rsync command as below:rsync --delay-updates -F --compress --archive --rsh=ssh... (2 Replies)
Discussion started by: mohtashims
2 Replies

2. AIX

AIX 6.1 Backups

Hello, I've got multiple AIX LPARs running on VIOS, within a blade environment. I need to dump a mksysb backup to backup rootvg and a couple of other volume groups. mksysb -i "destination"; works however I'd like to make sure its being done correctly. on the other volume groups, ive... (2 Replies)
Discussion started by: ollie01
2 Replies

3. UNIX for Advanced & Expert Users

Rsync Backups on HostGator VPS

I'm wanting to do remote backups of the entire /home/* directory structure, which is where HG puts all www files and sets the user and group independently of any other user ( so /home/user1 will be using group user1, instead of a generic apache group) The problem I'm running into is that only... (0 Replies)
Discussion started by: kettlewell
0 Replies

4. Shell Programming and Scripting

Rsync Scripts for Offsite backups

I am currently bringing up an offsite location, right now I am in the process of copying some data offsite (about 400GB). The problem I see is that running a single rsync for everything is not using the available bandwidth and testing shows that I double in speed for each instance of Rsync I am... (3 Replies)
Discussion started by: mchasse
3 Replies

5. UNIX Desktop Questions & Answers

Backups too CD

I've been handed the task of backing up some of our system files on a Solaris box. No probs. Zipped the logs that needed backing up but my superiors do not want it on tape, they want it spanned on CD's. The CD-Writer is available on a MS box. FTP'd the zipped logs across too the MS Machine but now... (1 Reply)
Discussion started by: mccrack_2003
1 Replies

6. UNIX for Advanced & Expert Users

backups in background

Hi, how i can do background backup process in Unix?? I has Solaris Operating System. very much thanks!! (4 Replies)
Discussion started by: jairog
4 Replies

7. UNIX for Dummies Questions & Answers

Backups.

Hello everyone my ? is about backups. I'am running SCO OS 505 and currently backing up the hole HD. Well the back up is taking too long and this is becoming a problem for the users since we are a 24-7 bussines, I whant stop backing up every thing on the HD. What are the most important files and... (1 Reply)
Discussion started by: kikkin
1 Replies

8. UNIX for Advanced & Expert Users

UNIX backups

hi, how do we go for the BACK UPS on the UNIX box,using DLT tapes.i need to back up the stuff on the DLT tape. pls HELP:( (4 Replies)
Discussion started by: saood
4 Replies

9. UNIX for Dummies Questions & Answers

backups

When using hostdump.sh to backup a system I can do it fine. But how can I restore what I backuped up? :) Thx in advance (2 Replies)
Discussion started by: merlin
2 Replies

10. Filesystems, Disks and Memory

Backups

I have been using the hostdump.sh backup script for over a year now and have recently run into a problem. I'm now getting the following error at the end of my jobs; /bin/mt -f: error fsf'ing tape. This script uses the native 'ufsdump'. So, I try to go back and read the last dump on the tape... (11 Replies)
Discussion started by: Solaris
11 Replies
Login or Register to Ask a Question