Skip to content

error calling CreateSQL: sql: expected 4 destination arguments in Scan, not 2 #275

Description

@dabico

I'm trying to integrate this project as a docker service into one of my existing projects. Here's the configuration residing in the docker-compose file:

version: '3.9'
name: 'test'

services:

  database:
    image: mysql:8.3.0
    container_name: database
    restart: "always"
    volumes:
      - data:/var/lib/mysql
      - ./mysql.cnf:/etc/mysql/conf.d/mysql.cnf
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: yes
      MYSQL_DATABASE: test
      MYSQL_USER: testadmin
      MYSQL_PASSWORD: examplePass123
      TZ: UTC
    healthcheck:
      test: mysqladmin ping -h localhost
      start_period: 10s
      interval: 10s
      timeout: 5s
      retries: 5
    labels:
      - "com.centurylinklabs.watchtower.scope=test"

  backup:
    image: databack/mysql-backup:1.0.0-rc2
    container_name: backup
    restart: "no"
    volumes:
      - backup:/home/appuser/backup
      - ./bkpdb/clean_pre.sh:/scripts.d/pre-backup/00_clean_flyway_history.sh
      - ./bkpdb/clean_post.sh:/scripts.d/post-backup/00_clean_old_dumps.sh
    environment:
      TZ: UTC
      DB_NAMES: test
      DB_PORT: 3306
      DB_USER: testadmin
      DB_PASS: examplePass123
      DB_SERVER: database
      DB_DUMP_BEGIN: "+0"
      DB_DUMP_TARGET: /home/appuser/backup
      DB_DUMP_DEBUG: true
      DB_DUMP_SAFECHARS: true
      MYSQLDUMP_OPTS: >-
        --quick
        --compact
        --events
        --triggers
        --routines
        --single-transaction
        --max-allowed-packet=1G
    command: dump
    depends_on:
      database:
        condition: service_healthy
    labels:
      - "com.centurylinklabs.watchtower.scope=test"
    networks:
      - default

  watchtower:
    image: containrrr/watchtower:latest
    container_name: watchtower
    restart: "no"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      WATCHTOWER_SCOPE: 'test'
      WATCHTOWER_TIMEOUT: '60s'
      WATCHTOWER_SCHEDULE: '0 0 */6 * * *'
      WATCHTOWER_LOG_LEVEL: 'debug'
      WATCHTOWER_INCLUDE_STOPPED: true
    labels:
      - "com.centurylinklabs.watchtower.scope=test"
    networks:
      - default

volumes:
  data:
    name: test-data
  backup:
    name: test-data-backups

networks:
  default:
    name: test-network

Attempting to run leads to the following error:

2024-03-06T10:32:40.556074895Z time="2024-03-06T10:32:40Z" level=info msg="beginning dump 2024-03-06T10:32:40Z"
2024-03-06T10:32:40.572913107Z Error: error backing up: failed to dump database: failed to dump database test: template: mysqldumpTable:9:3: executing "mysqldumpTable" at <.CreateSQL>: error calling CreateSQL: sql: expected 4 destination arguments in Scan, not 2
2024-03-06T10:32:40.573461507Z Usage:
2024-03-06T10:32:40.573473804Z   mysql-backup dump [flags]
2024-03-06T10:32:40.573476548Z 
2024-03-06T10:32:40.573478448Z Aliases:
2024-03-06T10:32:40.573514761Z   dump, backup
2024-03-06T10:32:40.573519105Z 
2024-03-06T10:32:40.573522603Z Flags:
2024-03-06T10:32:40.573526412Z       --begin 2330                         What time to do the first dump. Must be in one of two formats: Absolute: HHMM, e.g. 2330 or `0415`; or Relative: +MM, i.e. how many minutes after starting the container, e.g. `+0` (immediate), `+10` (in 10 minutes), or `+90` in an hour and a half (default "+0")
2024-03-06T10:32:40.573530657Z       --compression gzip                   Compression to use. Supported are: gzip, `bzip2` (default "gzip")
2024-03-06T10:32:40.573534189Z       --cron string                        Set the dump schedule using standard [crontab syntax](https://en.wikipedia.org/wiki/Cron), a single line.
2024-03-06T10:32:40.573537704Z       --exclude strings                    databases to exclude from the dump.
2024-03-06T10:32:40.573540818Z       --filename-pattern string            Pattern to use for filename in target. See documentation. (default "db_backup_{{ .now }}.{{ .compression }}")
2024-03-06T10:32:40.573544200Z       --frequency int                      how often to run backups, in minutes (default 1440)
2024-03-06T10:32:40.573547439Z   -h, --help                               help for dump
2024-03-06T10:32:40.573550233Z       --include strings                    names of databases to dump; empty to do all
2024-03-06T10:32:40.573553426Z       --max-allowed-packet int             Maximum size of the buffer for client/server communication, similar to mysqldump's max_allowed_packet. 0 means to use the default size. (default 4194304)
2024-03-06T10:32:40.573557321Z       --no-database-name USE <database>;   Omit USE <database>; in the dump, so it can be restored easily to a different database.
2024-03-06T10:32:40.573560858Z       --once                               Override all other settings and run the dump once immediately and exit. Useful if you use an external scheduler (e.g. as part of an orchestration solution like Cattle or Docker Swarm or [kubernetes cron jobs](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/)) and don't want the container to do the scheduling internally.
2024-03-06T10:32:40.573564398Z       --post-backup-scripts .sh            Directory wherein any file ending in .sh will be run post-backup but pre-send to target.
2024-03-06T10:32:40.573569179Z       --pre-backup-scripts .sh             Directory wherein any file ending in .sh will be run pre-backup.
2024-03-06T10:32:40.573572489Z       --safechars :                        The dump filename usually includes the character : in the date, to comply with RFC3339. Some systems and shells don't like that character. If true, will replace all `:` with `-`.
2024-03-06T10:32:40.573586853Z       --target strings                     full URL target to where the backups should be saved. Should be a directory. Accepts multiple targets. Supports three formats:
2024-03-06T10:32:40.573591757Z                                            Local: If if starts with a "/" character of "file:///", will dump to a local path, which should be volume-mounted.
2024-03-06T10:32:40.573595631Z                                            SMB: If it is a URL of the format smb://hostname/share/path/ then it will connect via SMB.
2024-03-06T10:32:40.573598840Z                                            S3: If it is a URL of the format s3://bucketname/path then it will connect via S3 protocol.
2024-03-06T10:32:40.573602493Z 
2024-03-06T10:32:40.573605409Z Global Flags:
2024-03-06T10:32:40.573608416Z       --aws-access-key-id string       Access Key for s3 and s3 interoperable systems; ignored if not using s3.
2024-03-06T10:32:40.573611740Z       --aws-endpoint-url string        Specify an alternative endpoint for s3 interoperable systems e.g. Digitalocean; ignored if not using s3.
2024-03-06T10:32:40.573615233Z       --aws-region string              Region for s3 and s3 interoperable systems; ignored if not using s3.
2024-03-06T10:32:40.573618488Z       --aws-secret-access-key string   Secret Access Key for s3 and s3 interoperable systems; ignored if not using s3.
2024-03-06T10:32:40.573621780Z       --config-file string             config file to use, if any; individual CLI flags override config file
2024-03-06T10:32:40.573625010Z       --pass string                    password for database server
2024-03-06T10:32:40.573628111Z       --port int                       port for database server (default 3306)
2024-03-06T10:32:40.573631243Z       --server string                  hostname for database server
2024-03-06T10:32:40.573634257Z       --smb-domain string              SMB domain
2024-03-06T10:32:40.573637117Z       --smb-pass string                SMB username
2024-03-06T10:32:40.573640114Z       --smb-user string                SMB username
2024-03-06T10:32:40.573642998Z       --tmp string                     temporary directory base for working directory, defaults to OS (default "/tmp")
2024-03-06T10:32:40.573646319Z       --user string                    username for database server
2024-03-06T10:32:40.573650116Z   -v, --verbose int                    set log level, 1 is debug, 2 is trace
2024-03-06T10:32:40.573653229Z 
2024-03-06T10:32:40.573656096Z time="2024-03-06T10:32:40Z" level=fatal msg="error backing up: failed to dump database: failed to dump database gse: template: mysqldumpTable:9:3: executing \"mysqldumpTable\" at <.CreateSQL>: error calling CreateSQL: sql: expected 4 destination arguments in Scan, not 2"

I should note that since this is an existing application, the database does already come with some data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions