reklama

RSYNC automatický skript error

FAT32

RSYNC automatický skript error
« kdy: 02. 08. 2018, 12:07:08 »
Ahoj všem,

potřeboal by jsem poradit. Mám automatický zálohovací skript, který zlobí a já nechápu proč. Při erroru to tahá cestu
Kód: [Vybrat]
/root/ssh a já nechápu proč..

Kód: [Vybrat]
#!/bin/bash
#VARIABLES DEFINE TO STORE COMMANDS AND VALUES.
TODAY_DATE=$(date +%Y%m%d) #Store current date
MKDIR=$(which mkdir)    #store mkdir command
RSYNC=$(which rsync)    #store rsync command
DEL=$(which rm)             #store rm command
TAR=$(which tar)             #store tar command
MAIL=$(which mail)         #store mail command
LOGFILE='/tmp/backup.log' #store path of log file & touch this file in /tmp directory

#ADD EMAIL ID IN MAILTO FOR GETTING NOTIFICATIONS IN MAIL
MAILTO='muj@email.com'
BODY="nnFor more information please check $LOGFILE.nnnThanks,n$0"

#CREATE DIRECTORY TO STORE BACKUP FILES
PRODBACKDIR=$TODAY_DATE/var/production-backup/

#IF CONDITION CHECK DIRECTORY IS PRESENT OR NOT AND IF NOT PRESENT CREATE DIRECTORY WITH PROVIDED DIR STRUCTURE.
if [ ! -d "{$PRODBACKDIR}" ] && [ `$MKDIR -p "$PRODBACKDIR"` ];
then
echo -e "Directory Created for site";
fi

#if [ ! -d “{$BLOGBACKDIR}” ] && [ `$MKDIR -p “$BLOGBACKDIR”` ];
#then
#echo -e “Directory Created for Production Blog Codebase”;
#fi

#REMOVE BACKUP FILES 7 DAYS OLDER
find /var/production-backup/ -mtime +7 -exec rm -rf {} ";"

#RSYNC COMMAND  TO SYNC CODE OR DATA FROM REMOTE SERVER TO LOCAL USING SSHPASS TO PASS PASSWORD OF REMOTE SERVER
sshpass -p 'password' $RSYNC --progress -rPz ssh -e backups@remotehost:/var/www/website $PRODBACKDIR

#FOR LOOP TO CHECK BACKUP FILES AND COMPRESSED IT WITH .TAR.GZ FILE WHICH SAVES DISK SPACE ON LOCAL SYSTEM AND ALSO REMOVE NON COMPRESSED FILES.

for DOC in $PRODBACKDIR; do
echo "`date '+%Y-%m-%d'` : ${DOC} backup started";
if [ -d ${DOC} ]; then
          FILENAME=$(echo $DOC | awk -F '/' '{print $NF}');
          TARFILE="$FILENAME-$TODAY_DATE.tar.gz";
          echo "`date '+%Y-%m-%d'` : ${DOC} archiving started.";
          $TAR -cvzf $PRODBACKDIR/$TARFILE $PRODBACKDIR/$FILENAME;

#IF CONDITION CHECK ERRORS WHILE CREATING TAR.GZ AND REPORT IF TAR COMMAND FAILS.
if [ $? -eq 0 ]; then
                       echo "`date '+%Y-%m-%d'` : ${DOC} archiving done."
                       $DEL -rf $PRODBACKDIR/$FILENAME
                       echo "`date '+%Y-%m-%d'` : ${DOC} deleting of non-archive directory done."
               else
                       echo "Error while creating tar."
                       echo -e "Error while creating tar file.$BODY" | $MAIL -s 'Error : Creating tar file' $MAILTO
                       exit 1
               fi
       fi
       echo "`date '+%Y-%m-%d %H:%M:%S'` : ${DOC} backup completed"
done


#SEND THE NOTIFICATION EMAIL AFTER SUCCESSFUL COMPLETION OF BACKUP.
echo -e "Backups successfully done for Production codebase" | $MAIL -s "Completed : Backup finished." $MAILTO

Error:
Kód: [Vybrat]
sending incremental file list
rsync: link_stat "/root/ssh" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1196) [sender=3.1.2]
2018-08-02 : 20180802/var/production-backup/ backup started
2018-08-02 : 20180802/var/production-backup/ archiving started.
20180802/var/production-backup/
2018-08-02 : 20180802/var/production-backup/ archiving done.
2018-08-02 : 20180802/var/production-backup/ deleting of non-archive directory done.
2018-08-02 10:06:25 : 20180802/var/production-backup/ backup completed

reklama


-/+

Re:RSYNC automatický skript error
« Odpověď #1 kdy: 02. 08. 2018, 12:18:13 »
A jak to poustis, cronem nebo nejak jinak? Pokud cronem hod sem radek z cronu.

FAT32

Re:RSYNC automatický skript error
« Odpověď #2 kdy: 02. 08. 2018, 12:19:16 »
A jak to poustis, cronem nebo nejak jinak? Pokud cronem hod sem radek z cronu.
Zatím jsem to jen zkoušel ručně
Kód: [Vybrat]
./backups.sh

phtrc

Re:RSYNC automatický skript error
« Odpověď #3 kdy: 02. 08. 2018, 12:30:09 »
Kód: [Vybrat]
sshpass -p 'password' $RSYNC --progress -rPz ssh -e backups@remotehost:/var/www/website $PRODBACKDIR

je tam prohozené ssh -e . Správně je -e ssh (viz man rsync)

FAT32

Re:RSYNC automatický skript error
« Odpověď #4 kdy: 02. 08. 2018, 13:11:34 »
Kód: [Vybrat]
sshpass -p 'password' $RSYNC --progress -rPz ssh -e backups@remotehost:/var/www/website $PRODBACKDIR

je tam prohozené ssh -e . Správně je -e ssh (viz man rsync)
Ježiš no jo :-) Taková pitomá chyba..díky.

reklama


 

reklama