I wanted to check what is the size of pg_backup
folder, so I used this command:
[postgres@server02 ~]$ pwd
/var/lib/pgsql
[postgres@server02 ~]$ ls -lh
total 4.0K
drwxr-x---. 7 postgres postgres 86 Oct 6 22:00 pg_backup
As seen in the above output, the size is 86 bytes.
Hovewer, pg_backup
directory itself contains several other directories:
[postgres@server02 ~]$ ls -lh pg_backup
total 0
drwxr-xr-x. 3 postgres postgres 121 Oct 2 23:00 20211002
drwxr-xr-x. 2 postgres postgres 109 Oct 3 22:00 20211003
drwxr-xr-x. 2 postgres postgres 109 Oct 4 22:00 20211004
drwxr-xr-x. 2 postgres postgres 109 Oct 5 22:00 20211005
drwxr-xr-x. 2 postgres postgres 109 Oct 6 22:00 20211006
[postgres@server02 ~]$
And then one of these sub-directories contains some big files:
[postgres@server02 ~]$ ls -lh pg_backup/20211006
total 23G
-rw-r--r--. 1 postgres postgres 23G Oct 6 23:21 file.dump
-rw-r--r--. 1 postgres postgres 418K Oct 6 22:00 backup_dba.dump
-rw-r--r--. 1 postgres postgres 1.4K Oct 6 22:00 backup_postgres.dump
-rw-r--r--. 1 postgres postgres 830 Oct 6 22:00 backup_dwh.dump
I confused why the ls -lh
command shows the size of pg_backup
as only 86 bytes if in reality this directory CONTAINS a number of larger sub-directories which in turn CONTAIN files that might reach 23GB in size? Why the total sum of the files in all sub-directories of pg_backup
is not reflected in the initial ls -lh
command?
du
command. – Zoredache Oct 07 '21 at 08:22