Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore Fail . #293

Closed
binooetomo opened this issue Oct 17, 2018 · 2 comments
Closed

Restore Fail . #293

binooetomo opened this issue Oct 17, 2018 · 2 comments

Comments

@binooetomo
Copy link

Dear All ...

I tried to restore from a backup file

root@djrad2 /opt/djrad# ./manage.py dbrestore -i /opt/gdrive/datadjrad/default-postgresql-2018-10-17-063622.psql
System check identified some issues:

WARNINGS:
hotspot.HsRadCSI.afterauth: (fields.W122) 'max_length' is ignored when used with IntegerField
        HINT: Remove 'max_length' from field
hotspot.HsRadClient.afterauth: (fields.W122) 'max_length' is ignored when used with IntegerField
        HINT: Remove 'max_length' from field
hotspot.HsUser.user: (fields.W342) Setting unique=True on a ForeignKey has the same effect as using a OneToOneField.
        HINT: ForeignKey(unique=True) is usually better served by a OneToOneField.
Restoring backup for database 'default' and server 'None'
Restoring: /opt/gdrive/datadjrad/default-postgresql-2018-10-17-063622.psql
Restore tempfile created: 8.0 MiB
Are you sure you want to continue? [Y/n] Y
Traceback (most recent call last):
  File "./manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/dbbackup/management/commands/dbrestore.py", line 54, in handle
    self._restore_backup()
  File "/usr/local/lib/python2.7/dist-packages/dbbackup/management/commands/dbrestore.py", line 94, in _restore_backup
    self.connector.restore_dump(input_file)
  File "/usr/local/lib/python2.7/dist-packages/dbbackup/db/base.py", line 90, in restore_dump
    result = self._restore_dump(dump)
  File "/usr/local/lib/python2.7/dist-packages/dbbackup/db/postgresql.py", line 54, in _restore_dump
    stdout, stderr = self.run_command(cmd, stdin=dump, env=self.restore_env)
  File "/usr/local/lib/python2.7/dist-packages/dbbackup/db/postgresql.py", line 21, in run_command
    return super(PgDumpConnector, self).run_command(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/dbbackup/db/base.py", line 144, in run_command
    "Error running: {}\n{}".format(command, stderr.read()))
dbbackup.db.exceptions.CommandConnectorError: Error running:  psql djrad --host=localhost --username=djrad --no-password --set ON_ERROR_STOP=on --single-transaction
ERROR:  constraint "hotspot_hsradcs_radclient_id_d673b456_fk_hotspot_hsradclient_id" of relation "hotspot_hsradcsi" does not exist


I do crosscheck using psql from shell, and got that "hotspot_hsradcsi" is already there.

djrad=> \dt;
********* QUERY **********
SELECT n.nspname as "Schema",
  c.relname as "Name",
  CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special' WHEN 'f' THEN 'foreign table' END as "Type",
  pg_catalog.pg_get_userbyid(c.relowner) as "Owner"
FROM pg_catalog.pg_class c
     LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','')
      AND n.nspname <> 'pg_catalog'
      AND n.nspname <> 'information_schema'
      AND n.nspname !~ '^pg_toast'
  AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1,2;
**************************

                  List of relations
 Schema |            Name            | Type  | Owner
--------+----------------------------+-------+-------
 public | auth_group                 | table | djrad
 public | auth_group_permissions     | table | djrad
 public | auth_permission            | table | djrad
 public | auth_user                  | table | djrad
 public | auth_user_groups           | table | djrad
 public | auth_user_user_permissions | table | djrad
 public | django_admin_log           | table | djrad
 public | django_content_type        | table | djrad
 public | django_migrations          | table | djrad
 public | django_session             | table | djrad
 public | hotspot_hsaccounting       | table | djrad
 public | hotspot_hsgroup            | table | djrad
 public | hotspot_hsknownmac         | table | djrad
 public | hotspot_hslease            | table | djrad
 public | hotspot_hspool             | table | djrad
 public | hotspot_hsportal           | table | djrad
 public | hotspot_hsradclient        | table | djrad
 public | hotspot_hsradcsi           | table | djrad
 public | hotspot_hsstation          | table | djrad
 public | hotspot_hsuser             | table | djrad
 public | hotspot_hsuserdevice       | table | djrad
(21 rows)

And here is database part my settings.py


DATABASES = {
    'default': {
        #'ENGINE': 'django.db.backends.sqlite3',
        #'ENGINE': 'django.db.backends.mysql',
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        #'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
        #'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
        'HOST':'localhost',
        'NAME': 'djrad',
        'USER': 'djrad',
        'PASSWORD': 'SuperSecretJoe',
    }
}

Kindly please give me any enlightenment.

Sincerely
-bino-
@ZuluPro
Copy link
Contributor

ZuluPro commented Nov 21, 2018

You have to deal with how you want to do your backups and your restore:

  • With/Without data
  • With/Without schema
  • Full/partial

As you use Postgresql I advise to use the binary connector.

@jonathan-s
Copy link
Contributor

Kind of related to #245, so close this issue once that is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants