Coder Social home page Coder Social logo

mosidevv / install-peertube Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kimsible/getpeer.tube

0.0 0.0 0.0 57 KB

Installing and upgrading of the PeerTube stack by one shell-command

License: GNU Affero General Public License v3.0

Shell 100.00%

install-peertube's Introduction

Install PeerTube

Installing and upgrading of the PeerTube stack with one SHELL command.

This script is based on the official docker production setup and runs on most x86-64 linux distributions.

WARNING: before any upgrade don't forget to backup your peertube installation.

Server requirements

  • x86-64 Linux Distribution updated
  • SSH access as root or sudoer user with sudo prefix
  • Access on port 25 (smtp), port 80 (http) and port 443 (https)
  • A Domain Name pointing to this server
  • Docker >= v17.06

Usage

Basic usage with cURL or Wget.

sh -c "$(curl -fsSL https://raw.github.com/kimsible/install-peertube/master/install.sh)"
sh -c "$(wget https://raw.github.com/kimsible/install-peertube/master/install.sh -O -)"

An upgrade will auto-fill environment variables MY_EMAIL_ADDRESS and MY_DOMAIN, when install you'll need to define them :

[email protected] MY_DOMAIN=domain.tld \
sh -c "$(curl -fsSL https://raw.github.com/kimsible/install-peertube/master/install.sh)"
[email protected] MY_DOMAIN=domain.tld \
sh -c "$(wget https://raw.github.com/kimsible/install-peertube/master/install.sh -O -)"

You can also download and run the script manually.

Steps

  • Check if the script is running as root
  • Check if the host works with systemd
  • Check if cURL or Wget are installed
  • Check if Docker >= v17.06 is installed
  • Stop existing peertube.service
  • Install or upgrade Compose binary from GitHub Releases
  • Create working directory /var/peertube
  • Create non-root system user owner of working directory
  • Get latest official compose setup of PeerTube stack from GitHub Raw
    • Generate or use existing PostgreSQL credentials
    • Use defined MY_EMAIL_ADDRESS and MY_DOMAIN or wait for editing updated .env
  • Create or update peertube.service
  • Pull latest images
  • Run peertube.service
  • Display PeerTube Admin Credentials once server up or error logs
  • Display PeerTube DKIM DNS TXT Record to configure into your Domain Name System zone

Backup / Restore

For each backup you'll need to dump the PostreSQL database :

Before backup

$ peertube postgres:dump /var/peertube/docker-volume/db.tar

For each restoration you need to down all container with :

Before restoration

$ peertube down

After restoration

$ peertube postgres:restore /var/peertube/docker-volume/db.tar
$ peertube up

Mirror Backup

The mirror backup may be between your production server and a remote cloud / FTP.

Production server requirements: rsync and sshpass.

Backup command

$ rsync -av --delete --ignore-times --exclude docker-volume/db /var/peertube/ username@remote-cloud:<backups-absolute-path>/var/peertube/

To include the backup command in a script without password prompt, you might use sshpass before :

$ sshpass -p yourpassword rsync -av --exclude docker-volume/db /var/peertube/ username@remote-cloud:<backups-absolute-path>/var/peertube/ --delete

Basic Restore command only for missing files

$ rsync -av --delete username@remote-cloud:<backups-absolute-path>/var/peertube/ /var/peertube/

Full Restore command

$ rsync -av --delete --ignore-times username@remote-cloud:<backups-absolute-path>/var/peertube /var/peertube

For specific protocol without rsync or SSH support like FTP, you might use rclone.

Crontab

  • Edit crontab with crontab -u root -e
  • Add this line to run it as docker user every day at 5:25am :
25 5  * * * /usr/bin/peertube-mirror

Incremential Backup

The incremential backup maybe between a local OrangePi / RaspberryPi with a connected external disk and the remote production server.

Local OPI/ RPI requirements : rsync, open-ssh and rsnapshot.

Operating system - fstab

First of all your need to configure :

  • OPI / RPI connected to internet and with a local SSH access;

  • External disk to fstab mounted on a home sub-directory :

Get UUID of your disk:

$ blkid
# /dev/sda1: UUID="7610ebc5-5231-4b59-830e-a9sacb84a" TYPE="ext4" PARTUUID="62a1e04b-b700-fc4e-5878-78863daf9b34"

Insert the line bellow into /etc/fstab

UUID=<UUID> <mounted-disk-absolute-path> auto    rw,user,auto    0    0

SSH keys

On local OPI / RPI, generate SSH keys:

$ ssh-keygen -t rsa

At last copy generated SSH keys from local OPI / RPI to the remote production server:

$ ssh-copy-id <user>@<remote-production>

Rsnapshot config

On local OPI / RPI, you need to configure rsnapshot.

Before, you may backup the original configuration:

$ mv /etc/rsnapshot.conf /etc/rsnapshot.conf.backup

And put this configuration into /etc/rsnapshot.conf :

Carefull, the space between args are tabs

config_version  1.2
snapshot_root   <mounted-disk-absolute-path>
cmd_cp    /bin/cp
cmd_rm    /bin/rm
cmd_rsync   /usr/bin/rsync
cmd_ssh   /usr/bin/ssh
cmd_logger    /usr/bin/logger
cmd_du    /usr/bin/du
cmd_rsnapshot_diff    /usr/bin/rsnapshot-diff
interval    hourly    6
interval    daily     7
interval    weekly    4
interval    monthly   3
verbose     2
loglevel    4
lockfile    /var/run/rsnapshot.pid
use_lazy_deletes    1
rsync_numtries      2
rsync_short_args        -a
rsync_long_args --delete --numeric-ids --relative --delete-excluded
backup_exec     ssh <user>@<remote-production> "/usr/sbin/peertube postgres:dump /var/peertube/docker-volume/db.tar"
backup  <user>@<remote-production>:/var/peertube  . exclude=docker-volume/db

Test this configuration with

$ rsnapshot configtest

Backup

$ rsnapshot daily

Basic Restore command only for missing files

$ rsync -av --delete <mounted-disk-absolute-path>/daily.<day>/var/pertube/  <user>@<remote-production>:/var/pertube/

Full Restore command

$ rsync -av --delete --ignore-times <mounted-disk-absolute-path>/daily.<day>/var/peertube/  <user>@<remote-production>:/var/pertube/

Crontab

On OPI / RPI:

  • Edit crontab with crontab -u root -e
  • Add this line to run it as docker user every day at 4:25am :
25 4  * * * /usr/bin/rsnapshot daily

Migration server to server

On the old server :

$ peertube postgres:dump /var/peertube/docker-volume/db.tar
$ peertube down
$ rsync -av --exclude docker-volume/db /var/peertube/ username@new-server:/var/peertube/

WARNING: this command could fail with docker-volume/traefik/acme.json and docker-volume/opendkim/keys/peertube.* if you do not have a root access on the old server, in this case, don't worry, you just need to copy them manually. =)

On the new server :

$ peertube postgres:up
$ peertube postgres:restore /var/peertube/docker-volume/db.tar
$ systemctl start peertube

Development

Basic usage with cURL or Wget.

GIT_BRANCH=develop sh -c "$(curl -fsSL https://raw.github.com/kimsible/install-peertube/develop/install.sh)"
GIT_BRANCH=develop sh -c "$(wget https://raw.github.com/kimsible/install-peertube/develop/install.sh -O -)"

This error occurs if you have already installed peertube in another working directory.

ERROR: Pool overlaps with other one on this address space

To solve that issue you need to stop all old running containers and remove all unsused networks created by these old ones.

docker stop $(docker ps -a -q)
docker network prune

Magic command to reset all docker containers, images, volumes and networks.

docker stop $(docker ps -a -q) & wait; docker rm $(docker ps -a -q) & wait; docker rmi $(docker images -a -q); docker volume rm $(docker volume ls -q) & wait; docker network prune -f

install-peertube's People

Contributors

kimsible avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.