Sponsored Content
Top Forums Shell Programming and Scripting Bash script to back up with rsync Post 302371053 by ajmoreti on Friday 13th of November 2009 08:44:41 AM
Old 11-13-2009
Bash script to back up with rsync

I'm trying to write a script to back up with rsync, the script I am posting below:

Code:
nomServer="shiva horus isis"
dirshiva="/etc /faturamento"
shivaListExc="/usr/local/bin/shivaListExclRsync"
dumpDir="$dumpFile/Shiva"
dateBkp=`date +%A`

for nServer in ${nomServer}
do
        dirServer="$dirBkp/$nServer"
        if [ ! -d $dirServer ]
        then
                mkdir $dirServer
        fi
        
        for sDir in dir${nServer}
        do
                rsync -C \
                -D \
                --recursive \
                --update \
                --links \
                --perms \
                --acls \
                --xattrs \
                --owner \
                --group \
                --times \
                --verbose \
                --progress \
                --partial \
                --numeric-ids \
                --specials \
                --exclude-from=${nServer}ListExc \
                $nServer:$sDir $dirServer

                dumpDir="$dumpFile/$nServer"
                if [ ! -d $dumpDir ]
                then
                        mkdir $dumpDir
                fi

                if [ ! -d $dateBkp ]
                then
                        mkdir $dumpDir/$dateBkp
                fi

                tar -zcvfp --atime-preserve --remove-files /$dumpDir              /$dateBkp$sDir.tar.gz /$dirServer$sDir
        done
done

my question:

Code:
dirshiva="/etc /faturamento"
shivaListExc="/usr/local/bin/shivaListExclRsync"



the first variable is an array but when I called it in for is failing.

Code:
for sDir in dir${nServer}



I need this variable to return the value "dirshiva", there's any way to do this? I tried in many ways and I confess that I had no success.

if anyone has any ideas, I am grateful.

att,

Amilcar

Last edited by ajmoreti; 11-13-2009 at 10:08 AM.. Reason: added code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

rsync back?

Hi, I am in the process of developing backup script using rsync, my code is bellow: EXCLUDE_DIR="/home/kannanpg/mscdr/src/ex1" rsync -az -e ssh -v --exclude $EXCLUDE_DIR --delete $HOSTTOBACKUP:$SOURCE $DR_BACKUP_DIR/daily.0 >$tempfile 2>&1 even my exclude dir is coping.. what is wrong in... (1 Reply)
Discussion started by: redlotus72
1 Replies

2. Shell Programming and Scripting

Bash rsync but move not delete

There might be an easy solution to my problem, or maybe not, but here it is. I am trying to rsync a Volume with 1.5 terabytes of data and send it via fibre channel to a raid array. Now normally when I rsync it scans through everything and, before copying anything, deletes any files that have... (1 Reply)
Discussion started by: Movomito
1 Replies

3. Shell Programming and Scripting

rsync bash php

Hello, I have a bash script update.sh that contains rsync --delete -avz -e ssh ${files} root@64.XX.XX.XX:/websites/red/ when I use that script ./update.sh as root, it works like a charm as I set up the private/public key properly. When run from a php script through the apache webserver <?php... (10 Replies)
Discussion started by: JCR
10 Replies

4. Shell Programming and Scripting

Reading output from terminal back into bash script

How can I get a bash script to wait and read and count $i messages that a running program (drbl clonezilla) sends to the console (terminal) and only then move on to the next line in the script when the count is matched (the next line is the last line of the script and is a reboot)? The script... (0 Replies)
Discussion started by: dp123
0 Replies

5. Shell Programming and Scripting

Bash Script Help...search then read from file: change text and pipe back...

Hello, I am trying to make a bash script that can pull data from a file and then change one part of said data. I want to search by username and pull the full line. That way there is a way to replace just one part of that line then return it back to the file. My Data is stored like: ... (1 Reply)
Discussion started by: serverfull
1 Replies

6. Shell Programming and Scripting

Bash shell script: Str(007) to int(7),increment it(8) & convert back to string(008)

Hi, I have the following requirement. There will be following text/line in a file (eg: search-build.txt) PRODUCT_VERSION="V:01.002.007.Build1234" I need to update the incremental build number (eg here 007) every time I give a build through script. I am able to search the string and get... (4 Replies)
Discussion started by: drwatson_droid
4 Replies

7. Shell Programming and Scripting

Rsync script to rewrite suffix - BASH, awk, sed, perl?

trying to write up a script to put the suffix back. heres what I have but can't get it to do anything :( would like it to be name.date.suffix rsync -zrlpoDtub --suffix=".`date +%Y%m%d%k%M%S`.~" --bwlimit=1024 /mymounts/test1/ /mymounts/test2/ while IFS=. read -r -u 9 -d '' name... (1 Reply)
Discussion started by: jmituzas
1 Replies

8. OS X (Apple)

Rsync for back up, external HD

Hello all! I am quite unsure with all options of rsync. Here my backup configuration: I am on Mac X (10.8) and want an exact copy of my HD to an external HD. I formatted the new USB drive with Mac OS extended (Journaled, Encrypted) and made in my shell the following command and got the... (9 Replies)
Discussion started by: marek
9 Replies

9. Shell Programming and Scripting

Rsync in bash script doesn't work even after placing pub key in target server

Hello Friends, My bash script is like this #!/bin/bash # request Bourne shell as shell for job #$ -S /bin/bash # assume current working directory as paths #$ -cwd #$ -N rsync-copy # # print date and time date rsync -rltD --progress "ssh -i /home/myname/.ssh/id_rsa"... (4 Replies)
Discussion started by: jacobs.smith
4 Replies

10. Shell Programming and Scripting

Terminal running bash/rsync script does not close with exit (MacOS High SIerra)

Hello, I am running a bash script to do an rsync back on a computer running MacOS High Sierra. This is the script I am using, #!/bin/bash # main backup location, trailing slash included backup_loc="/Volumes/Archive_Volume/00_macos_backup/" # generic backup function function backup {... (12 Replies)
Discussion started by: LMHmedchem
12 Replies
rsync_selinux(8)					rsync Selinux Policy documentation					  rsync_selinux(8)

NAME
rsync_selinux - Security Enhanced Linux Policy for the rsync daemon DESCRIPTION
Security-Enhanced Linux secures the rsync server via flexible mandatory access control. FILE_CONTEXTS SELinux requires files to have an extended attribute to define the file type. Policy governs the access daemons have to these files. If you want to share files using the rsync daemon, you must label the files and directories public_content_t. So if you created a special directory /var/rsync, you would need to label the directory with the chcon tool. chcon -t public_content_t /var/rsync To make this change permanent (survive a relabel), use the semanage command to add the change to file context configuration: semanage fcontext -a -t public_content_t "/var/rsync(/.*)?" This command adds the following entry to /etc/selinux/POLICYTYPE/contexts/files/file_contexts.local: /var/rsync(/.*)? system_u:object_r:publix_content_t:s0 Run the restorecon command to apply the changes: restorecon -R -v /var/rsync/ SHARING FILES
If you want to share files with multiple domains (Apache, FTP, rsync, Samba), you can set a file context of public_content_t and pub- lic_content_rw_t. These context allow any of the above domains to read the content. If you want a particular domain to write to the pub- lic_content_rw_t domain, you must set the appropriate boolean. allow_DOMAIN_anon_write. So for rsync you would execute: setsebool -P allow_rsync_anon_write=1 BOOLEANS
system-config-selinux is a GUI tool available to customize SELinux policy settings. AUTHOR
This manual page was written by Dan Walsh <dwalsh@redhat.com>. SEE ALSO
selinux(8), rsync(1), chcon(1), setsebool(8), semanage(8) dwalsh@redhat.com 17 Jan 2005 rsync_selinux(8)
All times are GMT -4. The time now is 03:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy