Initial Upload Backup Script Datei.
This commit is contained in:
81
oc2fb.sh
Normal file
81
oc2fb.sh
Normal file
@ -0,0 +1,81 @@
|
||||
#!/bin/bash
|
||||
# ***************************************************************************
|
||||
# * Copyright (C) 2016 by Ralf Kirchner <masterkir@gmx.de> *
|
||||
# * *
|
||||
# * 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 of the License, or *
|
||||
# * (at your option) any later version. *
|
||||
# * *
|
||||
# * 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, write to the *
|
||||
# * Free Software Foundation, Inc., *
|
||||
# * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
# ***************************************************************************
|
||||
|
||||
### FTP connection user name
|
||||
FUSER=""
|
||||
|
||||
### FTP connection password
|
||||
FPASS=""
|
||||
|
||||
### FTP server name
|
||||
FHOST=""
|
||||
|
||||
### OwnCloud data dir
|
||||
DATA=""
|
||||
|
||||
|
||||
|
||||
########## do not change bellow ############
|
||||
|
||||
# test required apps installed
|
||||
for i in lftp getfacl
|
||||
do
|
||||
if ! [ $(which $i) ]; then
|
||||
echo "$i is not installed." >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# check old logfile exist then delete
|
||||
if [ -e "/tmp/lftp.log" ]
|
||||
then
|
||||
rm /tmp/lftp.log
|
||||
fi
|
||||
|
||||
|
||||
|
||||
for i in $DATA
|
||||
do
|
||||
echo "###########################################################" >> /tmp/lftp.log
|
||||
echo "# Backup Start fuer: $DATA Verzeichnis..." >> /tmp/lftp.log
|
||||
echo "###########################################################" >> /tmp/lftp.log
|
||||
|
||||
# write directory owner and rights to file
|
||||
echo "Erstelle Rechte Liste: $i/dir-rights.list" >> /tmp/lftp.log
|
||||
getfacl --recursive $i > $i/dir-rights.list
|
||||
echo "Rechte Liste erstellt..." >> /tmp/lftp.log
|
||||
|
||||
# write data to FTP dir
|
||||
lftp <<EOF
|
||||
set ssl:verify-certificate no
|
||||
set cmd:parallel 5
|
||||
set xfer:log true
|
||||
set xfer:log-file /tmp/lftp.log
|
||||
set net:max-retries 1
|
||||
open $FHOST
|
||||
user $FUSER $FPASS
|
||||
mirror --reverse --delete --no-perms --use-cache --skip-noaccess --no-symlinks $i $i
|
||||
bye
|
||||
EOF
|
||||
|
||||
done
|
||||
|
||||
# send mail
|
||||
mailx -s "Backup Report" < /tmp/lftp.log "sadmin"
|
Reference in New Issue
Block a user