Backup All-Inkl Webserver via SSH (Files and database)

Login to the user you want to use for backing up at target system (in my case backupnc):
Change to its home ~ folder.

Generate SSH Private/Public Key:
ssh-keygen -t rsa -b 4096

(Find public key in ~/.ssh/id_rsa.pub)

Copy public Key into All-Inkl KAS:
see step 5 here: https://all-inkl.com/wichtig/anleitungen/kas/ssh/dateiverwaltung/verbindung-mit-terminal-auf-mac-aufbauen-public-key-verfahren_432.html

Connect manually and accept servers signature:
ssh remoteuser@remotehost -i /home/backupnc/.ssh/id_rsa

Bash Script with daily cron:

# Database
ssh user@webserver -i /home/backupnc/.ssh/id_rsa -v 'mysqldump DATABASE -uUSER -pPASSWORD > /www/htdocs/w123/backup-database/database.sql'

rsync -avztP --delete user@webserver:/www/htdocs/w123/backup-database/ -e "ssh -i /home/backupnc/.ssh/id_rsa" /mnt/net/smb/backupnc/database/

# Files
rsync -avztP --delete user@webserver:/www/htdocs/w123/www/ -e "ssh -i /home/backupnc/.ssh/id_rsa" /mnt/net/smb/backupnc/www/ --exclude ".DS_Store" --exclude "@eaDir" --exclude ".apdisk"

Advertisements

Jdownloader Seedbox on Debian vServer

The last ~1 year, I used my Raspi to run Jdownloader in headless mode (see post) and store/extract files on my local NAS.
As I wanted to have high bandwith access to that files from several locations, I deceided to set up a private server with some storage and access via CIFS/FTPS/SFTP/Webdavs for Kodi.
I figured out a hosting provider which offers a vServer monthly for about 5€ and additional storage for about 6€ (for 500GB). This storage can be accessed internally as well as externally via CIFS/FTPS/SFTP/Webdavs, which makes it very easy for me, because I do not need to care about setting up external access to the storage via the vServer.
All I had to to do is to set up JDownloader headless on the Debian minimal and to mount the storage (I am using CIFS):

Based on:
https://kaistech.wordpress.com/2016/01/31/jdownloader-headless-on-raspberry-pi/
https://misterunknown.de/blog/2016/05/jdownloader-headless-auf-debian-ubuntu-server-installieren.html

Login as root

mkdir /home/jd
useradd -g users -d /home/jd -s /bin/bash jd
chown -hvR jd /home/jd

apt-get install openjdk-7-jre-headless

su jd
mkdir /home/jd/jdownloader
cd /home/jd/jdownloader
wget http://installer.jdownloader.org/JDownloader.jar
java -jar JDownloader.jar
reboot

su jd
cd /home/jd/jdownloader
java -jar JDownloader.jar
(then press y to enter MyJdownloader Logins)
Exit with Strg-C

Exit su jd with “exit” (now you are root again)

touch /home/jd/jdownloader/JDownloader.pid
nano /etc/init.d/jdownloader
(insert from: https://gist.github.com/WtfJoke/45796a5cfb0e746c84eb0d5b4650e11c)

#! /bin/sh
### BEGIN INIT INFO
# Provides: JDownloader2
# Required-Start: networking
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: JDownloader2 server daemon
# Description: JDownloader2 server daemon
### END INIT INFO

DIR="/home/jd/jdownloader"
PIDFILE="$DIR/JDownloader.pid"
JAVA="/usr/bin/java"
PARAM="-Djava.awt.headless=true -jar $DIR/JDownloader.jar"
USER="jd"

start_daemon () {
start-stop-daemon --start --background --oknodo --chuid $USER --make-pidfile --pidfile $PIDFILE --exec $JAVA -- $PARAM
}

stop_daemon () {
start-stop-daemon --stop --pidfile $PIDFILE
}

# Switch case
case "$1" in
start)
# On start
echo "Start JDownloader"
start_daemon
;;

stop)
# On stop
echo "Stop JDownloader"
stop_daemon
;;

restart)
# On restart
echo "Restart JDownloader"
start_daemon
stop_daemon
;;
*)
# Default action
echo "(start|stop|restart)"
;;
esac

exit 0

chmod 755 /etc/init.d/jdownloader
systemctl daemon-reload
systemctl enable jdownloader
reboot

Storage connected with CIFS like this: https://anteru.net/blog/2014/09/20/2480/

Login as root

apt-get install autofs cifs-utils

For safety reasons disable some server services which came with autofs and cifs-utils:
systemctl disable rpcbind
(portmapper server which came with autofs)
systemctl disable smbd
(SAMBA server which came with cifs-utils)
systemctl disable nmbd
(Netbios server which came with cifs-utils)
reboot

check with “netstat -tuplen”
it should only show sshd listening on port 22 (IPv4 and IPv6), dhclient and systemd-timesyn.

mkdir /mnt/net
mkdir /mnt/net/smb
nano /etc/auto.master
-> insert: /mnt/net/smb /etc/auto.cifs-shares
su jd
nano /home/jd/.smbcredentials
-> insert:
username=
password=

exit

find id for user jd
cut -d: -f1,3 /etc/passwd
-> e.g. id=1000

nano /etc/auto.cifs-shares
-> insert: storage -fstype=cifs,rw,credentials=/home/jd/.smbcredentials,uid=1000 ://cifspathtoyourstorage/subfolder

service autofs restart

su jd
cd /mnt/net/smb/storage
touch test.txt

change JDownloader path via MyJdownloader to /mnt/net/smb/storage

In Expert settings change MyJDownloaderSettings: Direct Connect Mode to “Disable direct connections” (this will change Jdownloader not to open a public tcp port on your server!).

Set up IPv4 to IPv6 portforwarder on vServer

To be used of you are behind a DS-Lite Cable/DSL-Connection and only have a fixed IPV6 (and a floating NATed IPv4).
Same service like offered by Universal Portmapper from e.g. feste-ip.net

Login as root
apt-get install 6tunnel

e.g. for OpenVPN running on remote host
6tunnel localport remotehost remoteport
6tunnel 1194 homeserver.remote 1194
or
6tunnel 10000 homeserver.remote 1194

Show running processes of 6tunnel
ps aux | grep 6tunnel

Create bootup-start/stop-script:
nano /etc/init.d/6tunnel
Insert:

#! /bin/sh
### BEGIN INIT INFO
# Provides: 6tunnel
# Required-Start: networking
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: 6tunnel server daemon
# Description: 6tunnel server daemon
### END INIT INFO

PARAM="/usr/bin/6tunnel 10000 homeserver.remote 1194"
USER="root"

start_daemon () {
start-stop-daemon --start --background --oknodo --chuid $USER --exec $PARAM
}

stop_daemon () {
start-stop-daemon --stop --name 6tunnel
}

# Switch case
case "$1" in
start)
# On start
echo "Start 6tunnel"
start_daemon
;;

stop)
# On stop
echo "Stop 6tunnel"
stop_daemon
;;

restart)
# On restart
echo "Restart 6tunnel"
start_daemon
stop_daemon
;;
*)
# Default action
echo "(start|stop|restart)"
;;
esac

exit 0

chmod +x /etc/init.d/6tunnel

Test with:
/etc/init.d/6tunnel start
netstat -tulpen
/etc/init.d/6tunnel stop

systemctl daemon-reload
systemctl enable 6tunnel