I have a postgresql DB on an Azure VM with Linux installed. I need to restore a certain backup to it from a file called latest.dump
. I copied this file to /home/myuser
and then ran psql mydb < latest.dump
.
A lot of gibberish got output on the screen, e.g.
ERROR: invalid byte sequence for encoding "UTF8": 0xb3
invalid command \Jg�~J&�:�Qr�Ɩ����q���^�[1�����q)���G���҆C�|�
ERROR: invalid byte sequence for encoding "UTF8": 0xb5
invalid command \mJ�q����>�^�R����
invalid command \R
ܡI$�)�a�;���wg7Ei�}R%�Q����h&ஓ�L��܆��(
invalid command \I����3M��e�2Q�?/X������`+=|Y[``+��:��r
invalid command \�^c�v��rR
And once it ended, it left this string pre-entered on the command prompt:
62;9;c62;9;c62;9;c62;9;c62;9;c62;9;c62;9;c62;9;c62;9;c62;9;c62;9;c62;9;c62;9;c62;9;c62;9;c62;9;c62;9;c62;9;c62;9;c
If I press enter to that, I merely get a lot of command not found
errors.
Most puzzlingly, a new file has showed up at /home/myuser
(i.e. same level where latest.dump
is kept). It has the bizarre name ???2@ؾ>?yqus????>I?[ޏI??i?Ď
.
If I try to sudo rm ???2@ؾ>?yqus????>I?[ޏI??i?Ď
, I get rm: cannot remove ‘???2@ؾ’: No such file or directory
. And then if I do ls
again, I see two new files in /home/myuser other than latest.dump
and ???2@ؾ>?yqus????>I?[ޏI??i?Ď
. These new files being ?yqus????
and I?[ޏI??i?Ď
. I can delete these two, but never ???2@ؾ>?yqus????>I?[ޏI??i?Ď
. I notice that the two newly created files' names are part of the file name of the original file (where they appear separated by >
if you look closely).
By the way, I logged into my postgres DB to see if the restore had worked. It hadn't, no data was populated and psql mydb < latest.dump
essentially failed.
Can anyone point out what the hell is going on here and how can I remove these newly created errant file(s)?
Inside latest.dump
, I see SQL like:
^@^@^@^@^@^A^A^@^@^@^@^F^@^@^@public^A^A^@^@^@^@^N^@^@^@uauvuro0s8b9v4^@^E^@^@^@false^@^C^@^@^@246^A^A^@^@^@^C^@^@^@^@^@^@^@^@^@ñ^@^@^@^@^@^@^@^@^@^D^@^@^@1259^@^E^@^@^@44416^@^R^@^@^@links_grouptraffic^@^E^@^@^@TABLE^@^B^@^@^@^@±^@^@^@CREATE TABLE links_grouptraffic (
id integer NOT NULL,
visitor_id integer NOT NULL,
which_group_id integer NOT NULL,
"time" timestamp with time zone NOT NULL
);
And a lot of data 'gibberish' like:
¿f ^?zQUò}ÛMpá#" ^]äR¡g¤^E ¼å<9a>ÓÍ@î<98>,£+DØñW[^Mw<8f>Ív<9d>ñItâduM§[/úµ<8c>ÏVgý[D^W3^N^Z0<91>Õ]'/ݸ1<8c>Ã^T°<8b>ªÈw42Á<87>Ç@o#Ñ<99>á<9c>¹=^@/áÙ¢<8c>´M Sç<90>|<æÇ<9d><93>¥<9a>NÜ©^CáxuXÜî¬<89>Ü^NÙo<8c>ð³°^O§ p¸ñÌÔ3}+^Oâr<3M¾<9b>t<80>^D<84>A^CÈ<89>kå^^H±yò T^Bíâ"º d<85><85><88>o<89><80>±³^C¥Ä9½^V^W4<81>æ¨ïo^YO[(æÃù^M^RÁ<9e>Ò<8e>Ô§k=ý<87>vGõº><83>^Q^DÅ>Û<~¡Ô+í
Note: please ask for more information in case needed
First, to delete your file. Try using rm "filename" (i.e. put quotes around filename). If that doesn't work, the ?
in the filename is probably some other character. You can still delete it using its inode. Do ls -li
and note the inode number (at the left hand side). Next, simply run the command find . -inum <inode-number> -exec rm -i {} \;
. That should get rid of problem number 1.
Secondly, I suggest not using psql mydb < latest.dump
. Instead use pg_restore like so: pg_restore latest.dump -d mydb -U myuser
. Technically, that's the right way to go ahead for you. You may get further errors, but they won't be related to what you're seeing currently (and might even be ignorable). latest.dump
is probably a binary file, instead of being a text file. Good luck!