CKAN, Proxy setting, Virtual box and etc

Set the proxy on the shell:
export ftp_proxy=proxy_url
export http_proxy=proxy_url
export https_proxy=proxy_url

Set proxy on git installation:
git config –global http.proxy  proxy_url
git config –global https.proxy proxy_url

Set proxy for pip:
pip install –proxy proxy_url -r /usr/lib/ckan/default/src/ckan/requirements.txt
sudo /usr/lib/ckan/datapusher/bin/pip install –proxy proxy_url -r requirements.txt

=====================================================================
File Store Backup and Restore

Backup :
paster db dump -c /etc/ckan/default/production.ini my_database_dump.sql

Restore:
paster db clean -c /etc/ckan/default/production.ini
paster db load -c /etc/ckan/default/production.ini my_database_dump.sql

paster db init -c /etc/ckan/default/development.ini

Create Admin:
paster sysadmin add user_name-c /etc/ckan/default/production.ini

Create test data:
paster create-test-data -c /etc/ckan/default/production.ini

tar -czvf /home/user/Desktop/filestore_backup.tar.gz /var/lib/ckan/default
rm -rf /var/lib/ckan/default/*
tar xvf /home/user/Desktop/filestore_backup.tar.gz

cp -r var/lib/ckan/default/* /var/lib/ckan/default/
chmod -R 777 /var/lib/ckan/default/
sudo chown –R apache /var/lib/ckan/default
==================================================================
/var/lib/pgsql

su – postgres
pg_dump -U postgres -W -F p ckan_default > dump_ckan_default.sql

dropdb -U ckan_default -W ckan_default

=================================================================
Mounting in VirtualBox  :
http://serverfault.com/questions/674974/how-to-mount-a-virtualbox-shared-folder/674978

mkdir share
sudo mount -t vboxsf wd ~/share/

================================================================

Datastore

Insert in datastore
curl -X POST http://127.0.0.1:5000/api/3/action/datastore_create -H “Authorization: db125a88-ece7-4f27-9e6b-8a1bbd13faf6” -d ‘{“resource”: {“package_id”: “d0136066-6daf-4791-83b8-3dbbc0513a31”}, “fields”: [ {“id”: “a”}, {“id”: “b”} ], “records”: [ { “a”: 1, “b”: “45”}, {“a”: 2, “b”: “78”}, {“a”: 3, “b”: “8”}
, {“a”: 4, “b”: “38”}, {“a”: 5, “b”: “118”} ]}’

curl -X POST http://127.0.0.1:5000/api/3/action/datastore_create -H “Authorization: 03c076ad-e1a1-41c8-bf9d-2a35678dfd3b” -d ‘{“resource”: {“package_id”: “e00a3583-ae57-4155-bbd1-ae14d54ca4f3”}, “fields”: [ {“id”: “a”}, {“id”: “b”} ], “records”: [ { “a”: 1, “b”: “aaa”}, {“a”: 2, “b”: “bbb”} ]}’

delete a resource
curl -X POST http://127.0.0.1:5000/api/3/action/datastore_delete -H “Authorization: 03c076ad-e1a1-41c8-bf9d-2a35678dfd3b” -d ‘{“resource_id”: “9016e26a-3b56-4ea3-9da3-9283a003c01d”}’

View a resource:
http://127.0.0.1:5000/api/3/action/datastore_search?resource_id=RESOURCE_ID

http://127.0.0.1:5000/api/3/action/datastore_search?resource_id=4cc335d5-62f2-47dc-9894-4b8dad818862

DataPusher Installation:
http://docs.ckan.org/projects/datapusher/en/latest/

#create a virtualenv for datapusher
sudo virtualenv /usr/lib/ckan/datapusher

#create a source directory and switch to it
sudo mkdir /usr/lib/ckan/datapusher/src
cd /usr/lib/ckan/datapusher/src

#clone the source (always target the stable branch)
sudo git clone -b stable https://github.com/ckan/datapusher.git

#install the DataPusher and its requirements
cd datapusher
sudo /usr/lib/ckan/datapusher/bin/pip install -r requirements.txt
sudo /usr/lib/ckan/datapusher/bin/python setup.py develop

#copy the standard Apache config file
# (use deployment/datapusher.apache2-4.conf if you are running under Apache 2.4)
sudo cp deployment/datapusher.conf /etc/httpd/conf.d/datapusher.conf

#copy the standard DataPusher wsgi file
#(see note below if you are not using the default CKAN install location)
sudo cp deployment/datapusher.wsgi /etc/ckan/

#copy the standard DataPusher settings.
sudo cp deployment/datapusher_settings.py /etc/ckan/

#open up port 8800 on Apache where the DataPusher accepts connections.
#make sure you only run these 2 functions once otherwise you will need
#to manually edit /etc/apache2/ports.conf.
sudo sh -c ‘echo “NameVirtualHost *:8800” >> /etc/httpd/ports.conf’
sudo sh -c ‘echo “Listen 8800” >> /etc/httpd/ports.conf’

#enable DataPusher Apache site
sudo a2ensite datapusher

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s