Best way to backup PostgreSQL cluster before upgrade I noticed that PGDATA folder changes during an upgrade (which is normal as I use the pg_upgrade --links command), but I don't know the best way to backup up my cluster before the upgrade in order to restore it in case of failure.

AFAIK, the several ways to backup my cluster are: 


pg_dumpall
pg_basebackupp 
tar


I tested pg_dumpall and pg_basebackup, but I've seen that after doing an upgrade and restore, the size and files of PGDATA changed (like the WAL folder for example). 

Is this normal and which method is recommended to backup/restore cluster ?
AFAIK, the several ways to backup my cluster is : pg_dumpall, pg_basebackupp or tar.


Also, filesystem instantaneous snapshots if your filesystem/OS has this feature.

For small/medium databases it's probably OK to use any of these methods.

Choose the method which you feel most comfortable with.

With tar/cp backups remember to shutdown cluster before doing the backup.

Logical backups (pg_dump + pg_dumpall) have extra advantage of being portable (to other Pg versions). But the restore is a multi-step process, with Fs/directory it's just a plain replacement of contents.


  I tested pg_dumpall and pg_basebackup but I've seen that after doing
  an upgrade and restore, the size and files of PGDATA did changed (like
  WAL folder for example). Is it normal 


Yes, completely normal. I mean - if the difference is 100-fold then probably something fishy is going on, but it's normal that after dump/restore the on-disk size is smaller.