11 backups
kiara edited this page 2023-04-12 07:37:04 +00:00
  • dagelijkse greenhost backups voor geselecteerde servers
  • dagelijkse rsync naar transip voor alle greenhost servers
  • database failover server db2
  • google docs versie geschiedenis van bestanden
  • nextcloud versie geschiedenis van bestanden
  • airtable versie geschiedenis
  • version control via git
  • handmatige backups
  • dagelijkse cron jobs voor dbs (ongetest)

git

we hebben git repositories gehost op:

handmatige backups

disks

rsync -r --rsync-path="sudo rsync" $SERVER.bij1.net:$PATH ./mybkp

databases

(notities van https://trello.com/c/iAjHqtmx/34-losse-database)

sqlite

  • alle databases:
sqlite3 some.sqlite3 .dump > dump.sql
grep -i insert dump.sql > dump-insert.sql

mariadb

  • met db create statements: mysqldump --all-databases > dump.sql
  • zonder db create statements, voor als we die al via ansible maken: mysqldump --all-databases --no-create-db=TRUE > dump.sql
  • backup 1 table: mysqldump $DB $TABLE > dump.sql
  • restore (1 db): mysql $DB < dump.sql

postgresql

dumps hier gebruiken COPY statements.

  • alle databases: pg_dumpall > dump.sql
  • specifieke database:
    • naar 1 file: pg_dump db > dump.sql
    • naar files per tabel (voor db DB, gegeven lokale peer connectie met credentials via ~/.pgpass, van map om files in te doen):
      • for table in $(psql -h localhost -U $DB -d $DB -t -c "Select table_name From information_schema.tables Where table_type='BASE TABLE'");
        do pg_dump -h localhost -t $table -U $DB $DB > ./$table.sql;
        done;
        
  • restore (voor $USER, $DB, mypassword):
    • psql -U postgres -c "CREATE ROLE $USER WITH LOGIN ENCRYPTED PASSWORD 'mypassword';"
      psql -U postgres -c "CREATE DATABASE $DB;"
      psql -U postgres -c "GRANT ALL PRIVILEGES ON DATABASE mydb TO $USER;"
      psql -U postgres --set ON_ERROR_STOP=on < dump.sql