Find backup files in moodledata/filedir/

Using the DB for the site, run this query:

mysql> select id,filename,filesize,contenthash from mdl_files where filename like ‘%.mbz’;

Example of short output

id filename filesize contenthash
30142 backup-moodle2-course-98-certification_dl_7.5-20190418-0934.mbz 132098673 29276404a04217e4132df5bd84c62f58bc48e8c1
above made with zip

31079 backup-moodle2-course-98-certification_dl_7.5-20190815-0933.mbz 488311474 67558034a8e1e18136589366ded294c28132cacd
above made as .tar.gz

The last column is the contenthash and it will be used to find file by that name in moodledata/filedir/

cd /path/to/moodledata/filedir/
find ./ -name 29276404a04217e4132df5bd84c62f58bc48e8c1
shows
./29/27/29276404a04217e4132df5bd84c62f58bc48e8c1

To check file type:
file -b ./29/27/29276404a04217e4132df5bd84c62f58bc48e8c1
if above returns
Zip archive data, at least v2.0 to extract
The backup file was made at a time when Moodle was using zip for archiving courses and
there were issues with backing up courses whose backup file size 4 Gig or larger.

The second example given above:

file -b ./67/55/67558034a8e1e18136589366ded294c28132cacd

shows
gzip compressed data, from Unix
and is a backup made with archiving set to .tar.gz … which is the default now
for vr 3’s of Moodle. Reason file sizes are larger in this info, course has been used for a number
of years.

Copy those files out of moodledata/filedir/ and rename them using .mbz extensions so they can be used
to restore to other moodles.

From /path/to/moodledata/filedir/

mkdir /root/moodlebackups/

cp ./29/27/29276404a04217e4132df5bd84c62f58bc48e8c1 /root/moodlebackups/cid98-20190418.mbz

cp ./67/55/67558034a8e1e18136589366ded294c28132cacd /root/moodlebackups/cid98-20190815.mbz

[root@staging filedir]

# ls -l /root/moodlebackups/

-rw-r–r– 1 root root 132098673 Aug 15 09:47 cid98-20190418.mbz
-rw-r–r– 1 root root 488311474 Aug 15 09:48 cid98-20190815.mbz