Skip to content

Instantly share code, notes, and snippets.

@Inkimar
Created August 24, 2017 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Inkimar/2a8faf02dc8223e81a3c7d401741c976 to your computer and use it in GitHub Desktop.
Save Inkimar/2a8faf02dc8223e81a3c7d401741c976 to your computer and use it in GitHub Desktop.
backing up files from docker using an .env-file
Q1: use gpg in the script, fetch psw from file does not work ...
Q2: use scp to cp the file to a remote location
info: mysqldump + tarring all the redmine_files ... becomes an tar.
#!/bin/bash
source .env/.env.db
TARGET=tst
NOW=`date +"%Y-%m-%d"`
TARGET_DIR=$TARGET/$NOW
mkdir $TARGET_DIR
docker exec -it mariadb_redmine sh -c "mysqldump -u $user -p$psw $db > /tmp/redmine_$NOW.sql"
docker cp mariadb_redmine:/tmp/redmine_$NOW.sql $TARGET_DIR
tar -zcvf $TARGET_DIR/redmine-files_$NOW.tar.gz redmine-files
#tarring mysql-dump and redmine-files
cd $TARGET && tar -zcvf backup_$NOW.tar.gz $NOW
# sudo apt-get install gnupg2
#gpg -c
#gpg -c backup_$NOW.tar.gz #asks for password
#secure copy , scp, backup_$NOW.tar.gz
@Inkimar
Copy link
Author

Inkimar commented Sep 4, 2017

apt-get install gnupg2
using gpg2, non-interactive
gpg2 --yes --batch --passphrase=myname -c sales.spending.csv

@Inkimar
Copy link
Author

Inkimar commented Sep 4, 2017

or use --passphrase-file ....

#ascii
gpg2 --yes --batch --passphrase=xxxxx -a -c test.csv

#not ascii
gpg2 --yes --batch --passphrase-file .passfile -c test.csv

@Inkimar
Copy link
Author

Inkimar commented Sep 4, 2017

Installation : http://internetarchive.readthedocs.io/en/latest/installation.html

  1. sudo pip install internetarchive

http://internetarchive.readthedocs.io/en/latest/cli.html
http://internetarchive.readthedocs.io/en/latest/quickstart.html#configuring

  1. run the 'ia configure' , creates the file ./config/ia.ini
    template : ia upload <identifier> file1 file2 --metadata="mediatype:texts" --metadata="blah:arg"
  2. run : ``ia upload inkimar-testing-5 test.csv.asc --metadata="mediatype:texts"

response:

Error retrieving metadata from https://archive.org/metadata/inkimar-testing-5, You are attempting to make an HTTPS request on an insecure platform, please see:

	https://internetarchive.readthedocs.org/en/latest/troubleshooting.html#https-issues

@Inkimar
Copy link
Author

Inkimar commented Sep 5, 2017

https://internetarchive.readthedocs.io/en/latest/troubleshooting.html#https-issues

Test

If you are using a Python version earlier than 2.7.9, you might see InsecurePlatformWarning and SNIMissingWarning warnings and your requests might fail. There are a few options to address this issue:

        Upgrade your Python to version 2.7.9 or more recent.

        Install or upgrade the following Python modules as documented here: PyOpenSSL, ndg-httpsclient, and pyasn1.

        Use HTTP to make insecure requests in one of the following ways:

                Adding the following lines to your ia.ini config file (usually located at ~/.config/ia.ini or ~/.ia.ini):

                    [general]
                    secure = false


@Inkimar
Copy link
Author

Inkimar commented Sep 5, 2017

https://askubuntu.com/questions/725171/update-python-2-7-to-latest-version-of-2-x

sudo add-apt-repository ppa:jonathonf/python-2.7
sudo apt-get update
sudo apt-get install python2.7
python --version

@Inkimar
Copy link
Author

Inkimar commented Sep 5, 2017

updated python

$ python --version
Python 2.7.13+

removed .config/ia.ini
runnning ia configure once again.

$ ia configure
Enter your Archive.org credentials below to configure 'ia'.

Email address: inkimar@gmail.com
Password: 

Config saved to: /home/ingimar/.config/ia.ini

test to upload a file to my account
ia upload inkimar-testing-5 test.csv.asc --metadata="mediatype:texts"

Works!
ia upload inkimar-testing-5 test.csv.asc --metadata="mediatype:texts"
inkimar-testing-5:
uploading test.csv.asc: [################################] 1/1 - 00:00:00

@Inkimar
Copy link
Author

Inkimar commented Sep 5, 2017

From start to finsih.

  1. upgrade python (2.7.13+)
  2. mkdir .config
  3. sudo pip install internetarchive ( pip not installed)
  4. sudo apt-get install python-pip ... trouble ..
    https://askubuntu.com/questions/597906/how-to-install-pip-and-a-python-package-for-self-installed-python

upgrade pip
pip install --upgrade pip

try 3. again
3. sudo pip install internetarchive ( pip not installed)

  1. configure ia
    ia configure
    Config saved to: /root/.config/ia.ini

  2. try to upload a dummy-file.

@Inkimar
Copy link
Author

Inkimar commented Sep 5, 2017

gpg2 --yes --batch --passphrase-file .passfile_ingimar -a -c test-wrangler-1.txt
creates -> test-wrangler-1.txt.asc
gpg2 was already installed.

ia upload ingimar-wrangler_20170905 test-wrangler-1.txt.asc --metadata="mediatype:texts"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment