Unable to restore DB after Database change to Postgres (Django) - django

I have migrated from SQLite to Postgres, but now I am unable to restore my data on Postgres, i am using Django db-backup package, it is giving me this error on dbrestore command
Traceback (most recent call last):
File "C:\Users\atifs\Documents\food_deliveryapp\fooddelivery\manage.py", line 22, in <module>
main()
File "C:\Users\atifs\Documents\food_deliveryapp\fooddelivery\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\atifs\Documents\food_deliveryapp\virtual-env\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "C:\Users\atifs\Documents\food_deliveryapp\virtual-env\lib\site-packages\django\core\management\__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\atifs\Documents\food_deliveryapp\virtual-env\lib\site-packages\django\core\management\base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\atifs\Documents\food_deliveryapp\virtual-env\lib\site-packages\django\core\management\base.py", line 398, in execute
output = self.handle(*args, **options)
File "C:\Users\atifs\Documents\food_deliveryapp\virtual-env\lib\site-packages\dbbackup\management\commands\dbrestore.py", line 53, in handle
self._restore_backup()
File "C:\Users\atifs\Documents\food_deliveryapp\virtual-env\lib\site-packages\dbbackup\management\commands\dbrestore.py", line 94, in _restore_backup
self.connector.restore_dump(input_file)
File "C:\Users\atifs\Documents\food_deliveryapp\virtual-env\lib\site-packages\dbbackup\db\base.py", line 92, in restore_dump
result = self._restore_dump(dump)
File "C:\Users\atifs\Documents\food_deliveryapp\virtual-env\lib\site-packages\dbbackup\db\postgresql.py", line 56, in _restore_dump
stdout, stderr = self.run_command(cmd, stdin=dump, env=self.restore_env)
File "C:\Users\atifs\Documents\food_deliveryapp\virtual-env\lib\site-packages\dbbackup\db\postgresql.py", line 21, in run_command
return super(PgDumpConnector, self).run_command(*args, **kwargs)
File "C:\Users\atifs\Documents\food_deliveryapp\virtual-env\lib\site-packages\dbbackup\db\base.py", line 150, in run_command
raise exceptions.CommandConnectorError(
dbbackup.db.exceptions.CommandConnectorError: Error running: psql --host=localhost --port=5432 --username=postgres --no-password --set ON_ERROR_STOP=on --single-transaction postgres
ERROR: syntax error at or near "AUTOINCREMENT"
LINE 1: ...S "auth_group" ("id" integer NOT NULL PRIMARY KEY AUTOINCREM...

Related

django-elasticsearch-dsl with AWS elasticsearch

I'm trying to use AWS ElasticBeanStalk to deploy a Django app using django-elasticsearch-dsl and I need to run ./manage.py search_index --rebuild the first time I load it. So within my container commands I've got:
03_elasticsearch:
command: "source /opt/python/run/venv/bin/activate && ./src/manage.py search_index --rebuild"
The problem is it is waiting for a n/Y to the question Are you sure you want to delete the 'hjsm-local' indexes? [n/Y]:
How do I rebuild my indecies?
UPDATE
When I use
03_elasticsearch:
command: "source /opt/python/run/venv/bin/activate && ./src/manage.py search_index --rebuild -f"
I get this error
Traceback (most recent call last):
File "./src/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django_elasticsearch_dsl/management/commands/search_index.py", line 134, in handle
self._rebuild(models, options)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django_elasticsearch_dsl/management/commands/search_index.py", line 114, in _rebuild
self._create(models, options)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django_elasticsearch_dsl/management/commands/search_index.py", line 84, in _create
index.create()
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch_dsl/index.py", line 102, in create
self.connection.indices.create(index=self._name, body=self.to_dict(), **kwargs)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
return func(*args, params=params, **kwargs)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/client/indices.py", line 110, in create
params=params, body=body)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/transport.py", line 327, in perform_request
status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/connection/http_urllib3.py", line 110, in perform_request
self._raise_error(response.status, raw_data)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/connection/base.py", line 114, in _raise_error
raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.TransportError: <exception str() failed>
(ElasticBeanstalk::ExternalInvocationError)
As per the source code, include the -f parameter in your command to force the acceptance of the prompt.

Using django-elasticsearch-dsl with AWS ElasticSearch - raise HTTP_EXCEPTIONS.get(status_code, TransportError)

I'm trying to convert up a Django application using django-elasticsearch-dsl and a elasticsearch server to using AWS ElasticSearch which I am deploying using ElsaticBeanStalk
When I use
03_elasticsearch:
command: "source /opt/python/run/venv/bin/activate && ./src/manage.py search_index --rebuild -f"
I get this error
Creating index 'hjsm-local'
Traceback (most recent call last):
File "./src/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/python/run/venv/local/lib64/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django_elasticsearch_dsl/management/commands/search_index.py", line 134, in handle
self._rebuild(models, options)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django_elasticsearch_dsl/management/commands/search_index.py", line 114, in _rebuild
self._create(models, options)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django_elasticsearch_dsl/management/commands/search_index.py", line 84, in _create
index.create()
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch_dsl/index.py", line 102, in create
self.connection.indices.create(index=self._name, body=self.to_dict(), **kwargs)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/client/utils.py", line 69, in _wrapped
return func(*args, params=params, **kwargs)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/client/indices.py", line 110, in create
params=params, body=body)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/transport.py", line 327, in perform_request
status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/connection/http_urllib3.py", line 110, in perform_request
self._raise_error(response.status, raw_data)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/elasticsearch/connection/base.py", line 114, in _raise_error
raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
elasticsearch.exceptions.TransportError: <exception str() failed>
(ElasticBeanstalk::ExternalInvocationError)
I do not understand what this is telling me - can anyone advise?
UPDATE
I think I am getting an HTTP 406 error, but I do not understand why. If I run locally using localhost:9200 rather than my aws eleasticsearch server, it works fine.
The issue was it needed ElasticSearch 2.4. I have to setup a server with this running and when I connected through it worked!

How to migrate HUE 4.2 to HUE 4.4 on EMR cluster

I'm currently running an EMR 5.17.0 cluster with HUE 4.2, now I'm planning to upgrade my EMR to 5.24 and migrate the HUE from 4.2 to 4.4.
I've followed the instruction from AWS "How to migrate a Hue database from an existing Amazon EMR cluster"
https://aws.amazon.com/blogs/big-data/how-to-migrate-a-hue-database-from-an-existing-amazon-emr-cluster/
But I got below exception when I try to import the hue-mysql.json from my new cluster! seems the schedule not be supported on HUE 4.4, does anyone have any good suggestions on how to fix this?
[hadoop#ip-172-31-21-127 ~]$ sudo /usr/lib/hue/build/env/bin/hue loaddata hue-mysql.json
Traceback (most recent call last):
File "/usr/lib/hue/build/env/bin/hue", line 14, in <module>
load_entry_point('desktop', 'console_scripts', 'hue')()
File "/usr/lib/hue/desktop/core/src/desktop/manage_entry.py", line 216, in entry
execute_from_command_line(sys.argv)
File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/management/commands/loaddata.py", line 69, in handle
self.loaddata(fixture_labels)
File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/management/commands/loaddata.py", line 109, in loaddata
self.load_label(fixture_label)
File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/management/commands/loaddata.py", line 166, in load_label
for obj in objects:
File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/serializers/json.py", line 88, in Deserializer
six.reraise(DeserializationError, DeserializationError(e), sys.exc_info()[2])
File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/serializers/json.py", line 82, in Deserializer
for obj in PythonDeserializer(objects, **options):
File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/core/serializers/python.py", line 129, in Deserializer
field = Model._meta.get_field(field_name)
File "/usr/lib/hue/build/env/lib/python2.7/site-packages/Django-1.11.20-py2.7.egg/django/db/models/options.py", line 619, in get_field
raise FieldDoesNotExist("%s has no field named '%s'" % (self.object_name, field_name))
django.core.serializers.base.DeserializationError: Problem installing fixture '/home/hadoop/hue-mysql.json': ContentType has no field named 'name'

ImportError: No module named modilabs.utils.subprocess_timeout

I use KoboToolbox and run KOBOCAT but it give the following Errors when I run manage.py.It works perfect on the port but it shows A server error occurred. Please contact the administrator. And it shows that it cannot import ProcessTimeout.
Here is the the Error log:
Traceback (most recent call last):
File "manage.py", line 21, in
execute_from_command_line(sys.argv)
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/django/core/management/init.py", line 399, in execute_from_command_line
utility.execute()
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/django/core/management/init.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/djcelery/management/base.py", line 82, in run_from_argv
return super(CeleryCommand, self).run_from_argv(argv)
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.dict)
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/djcelery/management/base.py", line 75, in execute
super(CeleryCommand, self).execute(*args, **options)
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/djcelery/management/commands/celeryd.py", line 25, in handle
worker.run(**options)
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/celery/bin/worker.py", line 212, in run
state_db=self.node_format(state_db, hostname), **kwargs
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/celery/worker/init.py", line 95, in init
self.app.loader.init_worker()
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/celery/loaders/base.py", line 128, in init_worker
self.import_default_modules()
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/djcelery/loaders.py", line 141, in import_default_modules
self.autodiscover()
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/djcelery/loaders.py", line 144, in autodiscover
self.task_modules.update(mod.name for mod in autodiscover() or ())
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/djcelery/loaders.py", line 179, in autodiscover
for app in settings.INSTALLED_APPS])
File "/home/sakib/.virtualenvs/kc/local/lib/python2.7/site-packages/djcelery/loaders.py", line 203, in find_related_module
return importlib.import_module('{0}.{1}'.format(app, related_name))
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/home/sakib/d2WebApp/kobocat/onadata/apps/viewer/tasks.py", line 14, in
from onadata.libs.utils.logger_tools import mongo_sync_status, report_exception
File "/home/sakib/d2WebApp/kobocat/onadata/libs/utils/logger_tools.py", line 28, in
from modilabs.utils.subprocess_timeout import ProcessTimedOut
ImportError: No module named modilabs.utils.subprocess_timeout

Django 2.0 haystack whoosh update index, rebuild index throw error

I am using django 2.0 with haystack+whoosh as a search. I configured as it is said in the documentation. Occurred problem is when i run ./manage.py rebuild_index it shows this error:
Traceback (most recent call last):
File "./manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/django/core/management/base.py", line 335, in execute
output = self.handle(*args, **options)
File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/haystack/management/commands/rebuild_index.py", line 36, in handle
call_command('clear_index', **options)
File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/django/core/management/__init__.py", line 133, in call_command
', '.join(sorted(valid_options)),
TypeError: Unknown option(s) for clear_index command: batchsize, workers. Valid options are: commit, help, interactive, no_color, nocommit, noinput, pythonpath, settings, skip_checks, stderr, stdout, traceback, using, verbosity, version.
after that i tried update_index it shows me this error:
File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/haystack/management/commands/update_index.py", line 214, in handle self.update_backend(label, using)
File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/haystack/management/commands/update_index.py", line 257, in update_backend
commit=self.commit, max_retries=self.max_retries)
File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/haystack/management/commands/update_index.py", line 84, in do_update
backend.update(index, current_qs, commit=commit)
File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/haystack/backends/whoosh_backend.py", line 185, in update
doc = index.full_prepare(obj)
File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/haystack/indexes.py", line 208, in full_prepare
self.prepared_data = self.prepare(obj)
File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/haystack/indexes.py", line 199, in prepare
self.prepared_data[field.index_fieldname] = field.prepare(obj)
File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/haystack/fields.py", line 205, in prepare
return self.convert(super(CharField, self).prepare(obj))
File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/haystack/fields.py", line 88, in prepare
values = self.resolve_attributes_lookup(current_objects, attrs)
File "/home/zorig/.virtualenvs/ftm/lib/python3.5/site-packages/haystack/fields.py", line 131, in resolve_attributes_lookup
values.append(current_object())
TypeError: __call__() missing 1 required keyword-only argument: 'manager'
So has anyone faced this error? Is it related to django 2.0 because i managed it work well with django 1.11.
Your installed version of Haystack does not support Django 2.0. Support for Django 2.0 was added in Haystack 2.8, which was released in March 2018.