Backup Matrix Synapse PostgreSQL Database

This is part of a series of posts on backing up and restoring a backup for Matrix Synapse server. Synapse was installed using the matrix-docker-ansible deployment which while a little complicated can greatly ease management later on down the road. All the main components are in docker containers so we need to use docker to access.

https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/docs/maintenance-postgres.md#backing-up-postgresql

As the root user run

docker exec --env-file=/matrix/postgres/env-postgres-psql matrix-postgres pg_dumpall -h matrix-postgres | gzip -c > /matrix/postgres.sql.gz

This will dump the Postgres database in /matrix/postgres.sql.gz
We can use this later to restore to a new server or keep as a backup.

Configure rsnapshot on Ubuntu Server

rsnapshot is a utility that uses rsync to backup files locally or it can backup files from a remote server.

While trying to figure out a good solution for backing up an Ubuntu Server I decided to try rsnapshot, however since it can either create a local backup or pull a remote backup it needs to be configured to do that on the backup server side. It does not “push” a backup to a backup server.

Some helpful snippits from the man file.

rsnapshot will typically be invoked as root by a cron job, or series of cron jobs. It is possible, however, to run as any    arbitrary user with an alternate configuration file.
...
USAGE
        rsnapshot can be used by any user, but for system-wide backups you will probably want to run it as root.
...
NOTES
        Make sure your /etc/rsnapshot.conf file has all elements separated by tabs.  See
        /usr/share/doc/rsnapshot/examples/rsnapshot.conf.default.gz for a working example file.
    Make sure you put a trailing slash on the end of all directory references.  If you don't, you may have extra directories    created in your snapshots.  For more information on how the trailing slash is handled, see the rsync(1) manpage.

Overview

Scenario

Host A runs xyz application and host B is the backup server. We create a backup user on host A, host B then uses that user to ssh and rsync backups to itself.

  1. Create backup user
  2. Configure rysnc to be used without a password
  3. Setup SSH Key, aka Passwordless authentication (On backup server)
  4. Setup rsnapshot config (On backup server)
  5. Configure rsnapshot in crontab (On backup server)
  6. Final Testing

Create backup user

The following commands are fairly straight forward. Change backupuser to whatever you want to call your backup user.

sudo useradd -m backupuser
passwd backupuser
sudo usermod -a -G sudo backupuser

Configure rysnc to be used without a password

We need to setup the backup user to be able to use “sudo rsync” without having to input the user password. If we don’t use sudo we can’t access system files for backups. And if we have to manually input the password every time rsync runs, then the backups would not be automatic. The following link was helpful.

https://unix.stackexchange.com/questions/325100/proper-way-to-set-up-rsnapshot-over-ssh

All we need to do is create a file in /etc/sudoers.d/username and then tell it we don’t need to enter a password when “sudo rsync” is run.

sudo tee /etc/sudoers.d/backupuser <<<'backupuser ALL = (root) NOPASSWD: /usr/bin/rsync'

Setup SSH Key, aka Passwordless authentication (On backup server)

Log into the backup server

Create SSH keys. Note that since rsnapshot wants to run as root, we create the key and copy it as the root user.

sudo ssh-keygen

Accept all the defaults so we can login from the backup server without having to enter in a password.

Copy ssh key to the server we are wanting to back up

sudo ssh-copy-id backupuser@ip

enter in the password and the the key should get copied it over. Once complete, verify that you can login without having to enter in a password.

Setup rsnapshot config (On backup server)

Open up the rsnapshot config file and modify where appropriate. /etc/rsnapshot.conf

Change the path to where the snapshots are stored. By default it stores them under /.snapshots. I moved it under a local user as I am not needing to use rsnapshot to backup the local backup server files.


# SNAPSHOT ROOT DIRECTORY
snapshot_root /home/user/rsnapshot/snapshots/

Add a daily backup option under Backup levels

# BACKUP LEVELS / INTERVAL #
retain daily 6

Setup remote server to get a backup from. Replace ipaddress and directories as needed. hostname is the sever name. You can change to whatever you want.

### BACKUP POINTS / SCRIPTS ###
# LOCALHOST
# Comment or delete entries unless you want to backup those as well
# EXAMPLE.COM
backup  backupuser@ipaddress:/home/     hostname/       +rsync_long_args=--rsync-path="sudo rsync"

If you would like to back up multiple locations you can create multiple entries with different remote paths. Example locations to add

backup  backupuser@ipaddress:/etc/     hostname/       +rsync_long_args=--rsync-path="sudo rsync"
backup  backupuser@ipaddress:/usr/local/     hostname/       +rsync_long_args=--rsync-path="sudo rsync"

Verify that the config is good with

sudo rsnapshot configtest

It should return Syntax OK

Setup Crontab

sudo crontab -e

Add the following line to run rsnapshot at 3AM every day. More information about crontab can be found here.

0 3 * * * /usr/bin/rsnapshot daily

Final Testing

Manually run a backup to verify everything is set up correctly.

sudo rsnapshot daily

After it runs you can check the directory you specified in the config file to verify that the files did get copied.

GTX 1070 – ETH Hashrate and Power Consumption

Nvidia GTX 1070 ETH Hashrate and Power Consumption

The following is the estimated Hashrate and power consumption of a GTX 1070 based on web sources.

GTX 1070

Cost

Cost Used (eBay)
February 2021: $300 – $500

Hasrate for Ethash and Power Consumption

Hashrate: 26/Mhs

Power Consumption
Average: 130 W


Average Mhs Per Watt : 0.2/Mhs
Average Watts Per Mhs: 5 W

Profitability is about $2.97/day as of February 9, 2021

https://whattomine.com/coins/151-eth-ethash?hr=26&p=130&fee=0.0&cost=0.1&hcost=0.0&commit=Calculate

GTX 3090 – ETH Hashrate and Power Consumption

Nvidia GTX 1070 ETH Hashrate and Power Consumption

The following is the estimated Hashrate and power consumption of a GTX 1070 based on web sources.

GTX 1070

Cost

Cost Used (eBay)
February 2021: $300 – $500

Hasrate for Ethash and Power Consumption

Hashrate: 26/Mhs

Power Consumption
Average: 130 W


Average Mhs Per Watt : 0.2/Mhs
Average Watts Per Mhs: 5 W

Profitability is about $2.97/day as of February 9, 2021

https://whattomine.com/coins/151-eth-ethash?hr=26&p=130&fee=0.0&cost=0.1&hcost=0.0&commit=Calculate

Nvidia RTX 3080 – Hashrate and Power Consumption

Nvidia RTX 3080 ETH Hashrate and Power Consumption

The following is the estimated Hashrate and power consumption of a RTX 3080 based on web sources.

RTX 3080

Cost

Cost Used (eBay)
February 2021: $1600 – $2000

Hasrate for Ethash and Power Consumption

Hashrate: 97/Mhs

Power Consumption
Average: 250 W


Average Mhs Per Watt : 0.39/Mhs
Average Watts Per Mhs: 2.58 W

Profitability is about $12.45/day as of February 9, 2021

https://whattomine.com/coins/151-eth-ethash?hr=97.0&p=250.0&fee=0.0&cost=0.1&hcost=0.0&commit=Calculate

Nvidia RTX 3070 – Hashrate and Power Consumption

Nvidia RTX 3070 ETH Hashrate and Power Consumption

The following is the estimated Hashrate and power consumption of a RTX 3070 based on web sources.

RTX 3070

Cost

It seems that the hashrate and power consumption is basically the same as an RTX 3060 Ti

Cost Used (eBay)
February 2021: $950 – $1000

Hasrate for Ethash and Power Consumption

Hashrate: 62/Mhs

Power Consumption
Average: 122 W


Average Mhs Per Watt : 0.51/Mhs
Average Watts Per Mhs: 1.97 W

Profitability is about $8.39/day as of February 9, 2021

https://whattomine.com/coins/151-eth-ethash?hr=62&p=122&fee=0.0&cost=0.1&hcost=0.0&commit=Calculate

Nvidia RTX 3060 Ti – Hashrate and Power Consumption

Nvidia RTX 3060 Ti ETH Hashrate and Power Consumption

The following is the estimated Hashrate and power consumption of a RTX 3060 Ti based on web sources.

RTX 3060 Ti

Cost

Cost Used (eBay)
February 2021: $900 – $1000

Hasrate for Ethash and Power Consumption

Hashrate: 60/Mhs

Power Consumption
Average: 120 W


Average Mhs Per Watt : 0.5/Mhs
Average Watts Per Mhs: 2 W

Profitability is about $7.70/day as of February 9, 2021

https://whattomine.com/coins/151-eth-ethash?hr=60.0&p=120.0&fee=0.0&cost=0.1&hcost=0.0&commit=Calculate

Radeon RX 570 – Hashrate and Power Consumption

These are the average RX 570 hashrates I have been getting while mining Ethereum.

https://www.msi.com/Graphics-Card/Radeon-RX-570-ARMOR-8G-OC

RX 570 brand MSI Armour

Cost

Cost Used (eBay)
February 2021: $225 – $330

Hasrate and Power Consumption

Ethereum Ethash
Hashrate: 28.5/Mhs

Power Consumption
Range: 111 – 119 W
Average = ~115 W

Settings
Core: 1100
V: 800
Mem : 2000


Average Mhs Per Watt : 0.25/Mhs
Average Watts Per Mhs: 4.04 W

Profitability is about $3.36/day as of February 9, 2021

https://whattomine.com/coins/151-eth-ethash?hr=28.0&p=115.0&fee=0.0&cost=0.1&hcost=0.0&commit=Calculate

Radeon RX 580 – Hashrate and Power Consumption

These are the average RX 580 hashrates I have been getting while mining Ethereum.

https://www.msi.com/Graphics-Card/Radeon-RX-5700-MECH-OC

RX 580 brand MSI Gaming and Armour

Cost

Cost Used (eBay)
February 2021: $300 – $400

Hasrate and Power Consumption

Ethereum Ethash
Hashrate: 30/Mhs

Power Consumption
The power consumption seems to vary a bit between cards, some of them end up doing really well considering how old they are.
Range: 75 – 92 W
Average = ~84 W

Settings
Core: 1100
V: 800
Mem : 2100


Average Mhs Per Watt : 0.36/Mhs
Average Watts Per Mhs: 2.8 W

Profitability is about $3.68/day as of February 9, 2021

https://whattomine.com/coins/151-eth-ethash?hr=30.0&p=84.0&fee=0.0&cost=0.1&hcost=0.0&commit=Calculate

Radeon RX 5600 XT – Hashrate and Power Consumption

These are the average RX 5600 XT hashrate I have been getting while mining Ethereum.

https://www.msi.com/Graphics-Card/RADEON-RX-5600-XT-MECH-OC/

RX 5700 brand MSI

Cost

Cost New (NewEgg)
October 2020: ~$400
February 2021: Unavailable. Similar models $849 – $1000

Cost Used (eBay)
February 2021: $530 – $700

Status: Unavailable… Pretty much everywhere…

Hasrate and Power Consumption

Ethereum Ethash Hashrate
39/Mhs

Note that apparently there are some 5600 XT’s that don’t do as well mining and end up getting mid 30mhs

Power Consumption
Average = ~98 W

Settings
Core: 1400
Mem : 900

Average Mhs Per Watt : 0.39/Mhs
Average Watts Per Mhs: 2.45 W

Profitability is about $5/day as of February 9, 2021

https://whattomine.com/coins/151-eth-ethash?hr=39.0&p=98.0&fee=0.0&cost=0.1&hcost=0.0&commit=Calculate