Backup UISP Application Backup Files with Rsync

UISP runs inside of a docker container. To copy out the backup files we need to use the “docker cp” command.

sudo docker cp unms:/home/app/unms/data/unms-backups ./uisp-backups

This will copy the backups into ./uisp-backups directory.

On an Ubuntu system, docker needs sudo permissions. If you copy the backups with the above command, the backup files will be assigned to the root user and you will not be able to use your normal user to manipulate the files.

You can either add your current user to the Docker group, or change the files owner

sudo chown username:username -R ./uisp-backups/

We can now copy all the automatic backups with rsync

sudo rsync -a ./uisp-backups -e "ssh -p 22" backupuser@backuphost:/backups

You can also automate this with Cron by doing something like

1 1 * * 1 docker cp unms:/home/app/unms/data/unms-backups ~/uisp-backups && rsync -a ~/uisp-backups -e "ssh -p 22" backupuser@backuphost:/backups

Every Monday at 1:01AM, copy the current UISP automatic backups, then use rsync to copy them to a remote server.

This expects that the current user has permissions to call Docker without sudo.

Extract encrypted Signal backup

https://github.com/xeals/signal-back
More information at the above link

Installation of precompiled binary for Signal-Back

wget https://github.com/xeals/signal-back/releases/download/v0.1.7-alpha.2/signal-back_linux_amd64
chmod +x signal-back_linux_amd64
./signal-back_linux_amd64

Help info

Usage: signal-back_linux_amd64 COMMAND [OPTION…] BACKUPFILE
   --help, -h     show help
   --version, -v  print the version
 Commands: 
   format   Read and format the backup file
   analyse  Information about the backup file
   extract  Retrieve attachments from the backup
   check    Verify that a backup is readable
   help     Shows a list of commands or help for one command

Extract attachments from backup

Replace ~/Desktop/signal…backup with the path to your Signal backup.

./signal-back_linux_amd64 extract ~/Desktop/signal-2019-09-30-01-43-21.backup

It’ll ask for the password and then start pulling out the attachments and putting them in the current directory.

Export messages to CSV file

Default option is XML. CSV will let you open it up in Excel.

./signal-back_linux_amd64 format -f CSV --output signal-output.csv ~/Desktop/signal-2019-09-30-01-43-21.backup

Specify password to use

You can use the -p option to specify the password. It does not matter if there are spaces every 5 numbers or not. Also the -P option is suppose to let you use a file.

./signal-back_linux_amd64 extract -p "48294 55709 09123 94563 74662 12800" ~/Desktop/signal-2019-09-30-01-43-21.backup

Other help options

bob@localhost:~/Downloads/signal-back$ ./signal-back_linux_amd64 help
 Usage: signal-back_linux_amd64 COMMAND [OPTION…] BACKUPFILE
 --help, -h     show help
   --version, -v  print the version
 Commands:
   format   Read and format the backup file
   analyse  Information about the backup file
   extract  Retrieve attachments from the backup
   check    Verify that a backup is readable
   help     Shows a list of commands or help for one command
bob@localhost:~/Downloads/signal-back$ ./signal-back_linux_amd64 help format
 Usage: signal-back_linux_amd64 format [OPTION…] BACKUPFILE
 Parse and transform the backup file into other formats.
 Valid formats include: CSV, XML, RAW.
 --format FORMAT, -f FORMAT  output the backup as FORMAT (default: "xml")
   --message TYPE, -m TYPE     format TYPE messages (default: "sms")
   --output FILE, -o FILE      write decrypted format to FILE
   --password PASS, -p PASS    use PASS as password for backup file
   --pwdfile FILE, -P FILE     read password from FILE
   --verbose, -v               enable verbose logging output
bob@localhost:~/Downloads/signal-back$ ./signal-back_linux_amd64 help extract
 Usage: signal-back_linux_amd64 extract [OPTION…] BACKUPFILE
 Decrypt files embedded in the backup.
 --outdir DIRECTORY, -o DIRECTORY  output attachments to DIRECTORY
   --password PASS, -p PASS          use PASS as password for backup file
   --pwdfile FILE, -P FILE           read password from FILE
   --verbose, -v                     enable verbose logging output
bob@localhost:~/Downloads/signal-back$ 

Mikrotik Backup Script

This is a Linux script for creating and backing up backups on Mikroitk routers.

Features

  • Creates the backups automatically, no need to manually create a backup on the Mikrotik
  • Uses SSH and SCP for encrypted communication between the router and the server
  • Runs on linux
  • Easy to use command line interface
  • Can back up single or multiple routers

Future Features

These are features I am planning on adding to the script in the future

  • Ability to compare backups and remove duplicates
  • Make the script smarter so it can detect a backup on a router and leave it instead of deleting it
  • Add better logging
  • Add the functionality to upload the backups to an online service like DropBox, or OneDrive automatically
  • Add alert mechanism to alert you if a backup failed or router is unreachable

Current Bugs or limitations

  • Deletes all backups off of the router, so if you manually created a backup it will delete it without asking
  • To stop backing up a router, you’ll need to manually delete the IP address out of the IP database i.e(ip.lst file.)
  • It does not currently have the ability to delete backups

 

Requirements

  1. Linux box to run the script from and to store the backups.  You can run it from a laptop or VirtualBox.
  2. You’ll need the following programs for this script to work(fping, sshpass)
  3. The Linux box need to be able to ping the routers, if it can’t the script will fail

Installing

Download program

wget www.incredigeek.com/home/downloads/mtbackup/mtbackup.sh
chmod +x mtbackup.sh

Now open up the script and edit the variables at the top for your username, password, and where you want the backups.

 nano mtbackup.sh

When you have finished editing the variables, hit CTRL+x, and then “y” and then “enter” to save the file.

If you want to setup the script to backup on a regular basis then setup the script to run in cron.

Run “crontab -e” and add the following line

10 1 * * 1 cd /root/mtbackup-1.0/ & sh mtbackup -b

Hit CTRL+x, and then “y” and then “enter” to save the file.

Adding routers to backup

Adding routers is really easy.  All you have to do is run the script with the -a option and then the ip address and the script will check if it can reach the IP and then add it to the IP Database i.e.(ip.lst file that contains all the routers ip addresses)
./mtbackup.sh -a 192.168.88.1

Example:

[root@localhost mtbackup-1.0]# ./mtbackup.sh -a 192.168.88.1
#################################################################

This is a Mikrotik Backup Utility.  Still being updated and worked on!!!

#################################################################

Adding 192.168.88.1 to the ip DB
Added 192.168.88.1 to ipDB
[root@localhost mtbackup-1.0]#

Backing up all routers

You can manually backup all the routers by running the script with just the “-b” option.  It’ll read every IP in the IP database and create a backup for each one and put it in the backup folder with is normally “./backups”, you can change it in the variables portion of the script.

./mtbackup.sh -b

Other examples

List routers in the IP Database

 [root@localhost mtbackup-1.0]# ./mtbackup.sh -L
#################################################################
This is a Mikrotik Backup Utility. Still being updated and worked on!!!
#################################################################
Listing Hosts...
192.168.88.1
10.200.1.1
172.20.1.1
33.11.2.22
[root@localhost mtbackup-1.0]#

Backup Single router

[root@localhost mtbackup-1.0]# ./mtbackup.sh -B 192.168.88.1
#################################################################

This is the Mikrotik Backup Utility. Currently under construction!!!

#################################################################

Starting to do backup on 10.9.0.1

Configuration backup saved
[root@localhost mtbackup-1.0]#

Other commands

[root@localhost mtbackup-1.0]# ./mtbackup.sh -h
#################################################################

This is the Mikrotik Backup Utility.  Still being updated and worked on!!!

#################################################################

Usage
./mtbackup.sh [OPTIONS]
./mtbackup.sh -b 192.168.88.1

-l      List backups
-L      List Hosts
-b      Backup all hosts in the IP database
-B {ip} Backup Single Host, Specife IP
-a {ip} Add ip to IP database
-v      Version

[root@localhost mtbackup-1.0]#