Gå til innhold

Rsyncscript og passord


Anbefalte innlegg

Bruker dette scriptet men jeg er litt lei av å taste inn passord så hvor kan jeg legge passordet i dette scriptet

 

#!/bin/sh

 

# Simple rsync "driver" script. (Uses SSH as the transport layer.)

# http://www.scrounge.org/linux/rsync.html

 

# Demonstrates how to use rsync to back up a directory tree from a local

# machine to a remote machine. Then re-run the script, as needed, to keep

# the two machines "in sync." It only copies new or changed files and ignores

# identical files.

 

# Destination host machine name

DEST="192.168.1.5"

 

# User that rsync will connect as

# Are you sure that you want to run as root, though?

USER="root"

 

# Directory to copy from on the source machine.

BACKDIR="/www/"

 

# Directory to copy to on the destination machine.

DESTDIR="/media/usbdisk/"

 

Har ikke tatt med alt men det viktigste tror jeg

Lenke til kommentar
Videoannonse
Annonse

Har nå fått det til å funke med passord da jeg fikk laget keys til dette,men nå er det sånn att backupscriptet som jeg har i /cron.hourly/ ikke kjører men ser i auth.loggen att den logger inn.Her er scriptet så lurer på om noen kan hjelpe meg med hva som er galt

 

#!/bin/sh

# Simple rsync "driver" script.  (Uses SSH as the transport layer.)
# http://www.scrounge.org/linux/rsync.html

# Demonstrates how to use rsync to back up a directory tree from a local
# machine to a remote machine.  Then re-run the script, as needed, to keep
# the two machines "in sync."  It only copies new or changed files and ignores
# identical files.

# Destination host machine name
DEST="192.168.1.5"

# User that rsync will connect as
# Are you sure that you want to run as root, though?
USER="root"

# Directory to copy from on the source machine.
BACKDIR="/www/"

# Directory to copy to on the destination machine.
DESTDIR="/media/usbdisk/www/"

# excludes file - Contains wildcard patterns of files to exclude.
# i.e., *~, *.bak, etc.  One "pattern" per line.
# You must create this file.
# EXCLUDES=/root/bin/excludes

# Options.
# -n Don't do any copying, but display what rsync *would* copy. For testing.
# -a Archive. Mainly propogate file permissions, ownership, timestamp, etc.
# -u Update. Don't copy file if file on destination is newer.
# -v Verbose -vv More verbose. -vvv Even more verbose.
# See man rsync for other options.

# For testing.  Only displays what rsync *would* do and does no actual copying.
#OPTS="-n -vv -u -a --rsh=ssh --exclude-from=$EXCLUDES --stats --progress"
# Does copy, but still gives a verbose display of what it is doing
OPTS="-v -u -a --rsh=ssh --exclude-from=$EXCLUDES --stats"
# Copies and does no display at all.
#OPTS="--archive --update --rsh=ssh --exclude-from=$EXCLUDES --quiet"

# May be needed if run by cron?
export PATH=$PATH:/bin:/usr/bin:/usr/local/bin

# Only run rsync if $DEST responds.
VAR=`ping -s 1 -c 1 $DEST > /dev/null; echo $?`
if [ $VAR -eq 0 ]; then
rsync $OPTS $BACKDIR $USER@$DEST:$DESTDIR
else
echo "Cannot connect to $DEST."

Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
  • Hvem er aktive   0 medlemmer

    • Ingen innloggede medlemmer aktive
×
×
  • Opprett ny...