Install Docker on Debian 9

Here is a simple script to install docker on Debian 9

  1. Create the script text file with nano
sudo nano

2. Copy this code to the file and save it

# Run this script to install Docker on Debian 9

#Install prerequisites
sudo apt update
sudo apt -yes install apt-transport-https ca-certificates curl gnupg2 software-properties-common

# Add the GPG key for the official Docker repository to your system:
curl -fsSL | sudo apt-key add -

# Add the Docker repository:
sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"

# Istall Docker
sudo apt update
sudo apt install -y docker-ce docker-ce-cli docker-compose

# Show from which repository DOCKER will be installed
echo "--- We are goint to install DOCKER from below repo ---
apt-cache policy docker-ce

echo "---------------- INSTALLATION FINISHED ---------------"

# Check docker status
sudo systemctl status docker

3. Make it executable:

chmod +x

4. Run the script

sudo ./

P.S. it might work on other systems aside fro Debian 9, but tested on Debian 9. This script is intended to simplify Docker setup in case I need it in the future.

Time Machine alternative for linux: automate your backups


MacOS has a good backup system which allows you to recover any files that have beed deleted or to restore previous versions of the files. I works like you can literally come back into a certain moment back in time.

Now that I have set up Raspberry Pi based home NAS, I found a solution that achieves the same results on linux: incrental backups with rsync.

Instruction: how to automate backups on Linux

Step 1. Set up rsync backup script, with instructions and settings on how to run the backup

sudo mkdir /usr/local/scripts      #to make folder to store scripts
sudo touch /usr/local/scripts/ # to create the script
sudo chmod +x  /usr/local/scripts/  # make it executable
sudo nano /usr/local/scripts/  #THEN EDIT THE SCRIPT:

Copy this code into the script:

# This script makes backups from DATADIR to BACKUPDIR and puts in 
# date-named folders corresponding to date of each backup
# SYNTAX:  $ ./ </DATADIR/ ($1)> </BACKUPDIR/ ($2)>
# Example: $ ./ /media/data/ /media/backup/

# To be able to use CTRL+C to exit script:
trap "exit" INT 

# Define the directories for backup
LAST_BACKUP_PATH=$2/$(ls $2 | tail -n 1)

# Make the backup
rsync -av --link-dest ${LAST_BACKUP_PATH} ${DATA} ${THIS_BACKUP_PATH}

# Move the backup to date-named folder after it's finished
mv $2/backup_in_progress $2$(date +%Y-%m-%d)

Step 2. Set up cron job to run the backup script on a schedule

sudo crontab -e

To backup DATA_DIR to BACKUP_DIR at 3am every night, add this to your cron file:

# WHEN       SCRIPT DIR                    DATA_DIR     BACKUP_DIR
  0 4 1 * *  /usr/local/scripts/  /data/dir/  /backup/dir
  0 3 * * *  /usr/local/scripts/  /data2/dir/ /backup2/dir
# - - - - -  CRON SYNTAX explained below:
# | | | | |
# | | | | ----- Day of week (0 - 7) (Sunday=0 or 7)
# | | | ------- Month (1 - 12)
# | | --------- Day of month (1 - 31)
# | ----------- Hour (0 - 23)
# ------------- Minute (0 - 59)

Useful Links

More on cron read here, or crontab calculator here

Bash scripts 101