Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:00,240 --> 00:00:07,350
In this video, we are going to cover some of the issues that students face while restoring a database.
1
2
00:00:08,350 --> 00:00:11,120
There are two main reasons of facing issue.
2
3
00:00:12,400 --> 00:00:19,700
The first reason is that the students do not create new database while restoring and try to restore
3
4
00:00:19,720 --> 00:00:22,380
a database within an old database.
4
5
00:00:23,360 --> 00:00:30,620
And the second reason occurs when Postgress team brings an update to the software or launches a new
5
6
00:00:30,620 --> 00:00:38,810
version of the software so many times the newer version is unable to restore files created in the older
6
7
00:00:38,810 --> 00:00:43,280
version or there are some other restoration issues with the newer version.
7
8
00:00:44,250 --> 00:00:51,440
For example, this is one of the issues which is usually seen in the 13th version of PostgreSQL.
8
9
00:00:52,560 --> 00:00:59,510
So if you see an error like this, that there is a location and at the end there is this file
9
10
00:00:59,520 --> 00:01:07,350
pg_restore.exe, this file is not found and it says that we have to correct the binary path
10
11
00:01:07,350 --> 00:01:08,710
in the preferences dialogue.
11
12
00:01:09,780 --> 00:01:17,550
So the reason for this issue is that the pg_restore.exe file, which is required to restore
12
13
00:01:17,550 --> 00:01:18,420
any database.
13
14
00:01:19,530 --> 00:01:27,360
This file is actually located at some other location and the location that pgAdmin4 has for
14
15
00:01:27,360 --> 00:01:29,220
that file is something else.
15
16
00:01:30,180 --> 00:01:35,630
So this location written here, this is the location available with our pgAdmin software.
16
17
00:01:36,360 --> 00:01:43,010
But if you go and search for the file on your system, this file will be located at some other location.
17
18
00:01:44,010 --> 00:01:49,880
So we have to change the location of this file in pgAdmin so that this error does not occur.
18
19
00:01:50,840 --> 00:01:54,560
So to do that, we have to first find the file on our pc
19
20
00:01:55,400 --> 00:01:58,730
Let me show you where this file is on my PC.
20
21
00:02:00,860 --> 00:02:08,750
So this is the postgress installation folder on my PC C program files postgreSQL and I'm using the
21
22
00:02:08,750 --> 00:02:09,460
12th version.
22
23
00:02:09,920 --> 00:02:14,720
And here there is a folder called bin. If I open this folder.
23
24
00:02:16,160 --> 00:02:22,970
And I scroll down, you will see that here's the file pg_restore.exe
24
25
00:02:23,930 --> 00:02:25,390
So this is an application file.
25
26
00:02:25,610 --> 00:02:34,310
So Dot exe, this file is used to restore the database and the location of this file is C program files.
26
27
00:02:34,640 --> 00:02:36,900
PostgreSQL 12 bin
27
28
00:02:38,000 --> 00:02:42,860
Now where do I have to put this location in pgAdmin.
28
29
00:02:43,160 --> 00:02:43,940
Let's see that.
29
30
00:02:44,990 --> 00:02:46,190
So in pgAdmin.
30
31
00:02:47,070 --> 00:02:51,420
You have to open this file menu, go to the preferences option.
31
32
00:02:54,040 --> 00:03:01,690
Here there is an option called binary parts on the left, click on it, and here you will see this option
32
33
00:03:01,690 --> 00:03:04,430
of both postgreSQL binary path.
33
34
00:03:05,470 --> 00:03:08,220
So this is the path that you have to change.
34
35
00:03:09,040 --> 00:03:13,800
For me, it is taking the path at runtime and it is taking the right path.
35
36
00:03:14,380 --> 00:03:19,460
But for you, if it is not taking the right path, you have to paste that path here.
36
37
00:03:20,440 --> 00:03:22,840
So the path is this C program files.
37
38
00:03:22,840 --> 00:03:24,220
PostgreSQL\12\bin
38
39
00:03:24,580 --> 00:03:27,730
Do not add pg_restore.exe after that.
39
40
00:03:28,060 --> 00:03:31,560
Just copy this folder location and paste it here.
40
41
00:03:32,560 --> 00:03:37,960
Save it and once you have done it try restoring again and you will not see this issue coming up.
41
42
00:03:38,980 --> 00:03:44,560
Another very common issue faced during restoration is failed with exit code 1.
42
43
00:03:45,490 --> 00:03:47,680
Now, again, there can be two reasons for this.
43
44
00:03:47,770 --> 00:03:49,900
One is we are not using a new DB.
44
45
00:03:51,010 --> 00:03:58,420
So always make sure that when you are restoring, always create a new database and to create a new database,
45
46
00:03:58,420 --> 00:03:58,870
you have to.
46
47
00:03:58,870 --> 00:03:59,100
Right.
47
48
00:03:59,110 --> 00:04:03,070
Click on databases, go to create and click on database.
48
49
00:04:04,860 --> 00:04:11,820
Name the database, and only in that new database, you have to restore the file, do not restore the
49
50
00:04:11,820 --> 00:04:18,060
files given in an older database because that in most of the cases will give you this error.
50
51
00:04:20,040 --> 00:04:25,260
Now, if you're sure that you're using a new database, then the next thing is you have to select the
51
52
00:04:25,290 --> 00:04:26,310
tar file to restore.
52
53
00:04:27,570 --> 00:04:30,290
Now, I've given you two versions of tar files.
53
54
00:04:31,140 --> 00:04:39,420
The issue here is that if I created the backup tar file in 9th version of PostgreSQL you are using,
54
55
00:04:39,720 --> 00:04:44,130
say, the 12th version or the 13th version, you will see an error.
55
56
00:04:44,940 --> 00:04:51,990
So if the file is created in some other version and you are using it to restore database in some other
56
57
00:04:51,990 --> 00:04:54,570
version, it usually gives up this error.
57
58
00:04:55,380 --> 00:04:58,130
So I have given you tar files for two versions.
58
59
00:04:58,800 --> 00:05:00,660
Try it out with both the tar files.
59
60
00:05:01,020 --> 00:05:07,030
If it still does not work out, I have given you another file which has the extension.backup.
60
61
00:05:07,620 --> 00:05:16,050
So this file also has the same data set inside it, only that the format is not tar. The format
61
62
00:05:16,050 --> 00:05:17,480
is dot backup.
62
63
00:05:18,570 --> 00:05:21,500
The process for selecting the backup file is also same.
63
64
00:05:22,320 --> 00:05:24,090
So you have to create a new database.
64
65
00:05:28,640 --> 00:05:35,630
So I have created this database with the name backup file here, right, click on it, go to restore.
65
66
00:05:36,990 --> 00:05:41,610
Now, in the file name, I'll have to go and select the backup file.
66
67
00:05:43,750 --> 00:05:50,860
So you can select the supermart_db.backup file and click on this select button,
67
68
00:05:51,860 --> 00:05:58,060
click on Restored and it will restore the same backup data from the dot backup file.
68
69
00:05:59,940 --> 00:06:09,240
Now, if that backup file option also does not work for you, so in future, if in some version of this
69
70
00:06:09,520 --> 00:06:16,730
backup file also does not work out, there is another option of this dot SQL file
70
71
00:06:17,190 --> 00:06:21,030
Try restoring the database using this dot SQL file.
71
72
00:06:22,080 --> 00:06:28,830
Apart from this, I have given you another option of restoring using a directory, so let me show you
72
73
00:06:28,830 --> 00:06:31,020
how restoration is done using a directory.
73
74
00:06:31,230 --> 00:06:35,700
So if you are restoring from our directory, let's create a new database.
74
75
00:06:38,260 --> 00:06:39,760
From directory.
75
76
00:06:44,790 --> 00:06:53,580
Now, when I select restored here, instead of having the format as custom or tar, select directory here
76
77
00:06:54,300 --> 00:07:02,280
and in the file name, so you do not have to click on any of the files, just select this folder, which
77
78
00:07:02,280 --> 00:07:06,340
is titled restore directory inside this folder.
78
79
00:07:06,360 --> 00:07:07,860
We have restoration files.
79
80
00:07:08,310 --> 00:07:10,590
You do not have to select individual files.
80
81
00:07:10,740 --> 00:07:13,980
Just select this folder and click on restore.
81
82
00:07:17,040 --> 00:07:20,370
And now, if you refresh the database.
82
83
00:07:22,930 --> 00:07:23,980
Go to schemas.
83
84
00:07:26,380 --> 00:07:34,000
Look at the tables, you'll see that the three tables have been created, so these are all the ways
84
85
00:07:34,000 --> 00:07:36,080
in which you can restore the database.
85
86
00:07:36,610 --> 00:07:43,210
We have tar files, we have backup file, we have SQL file, and we have a restoration directory.
86
87
00:07:43,720 --> 00:07:44,890
Try all of these out.
87
88
00:07:45,730 --> 00:07:51,690
And once you restore the database, refresh it to check if the tables are created or not.
88
89
00:07:52,540 --> 00:07:57,070
Sometimes this failure code is shown, but the tables are still created.
89
90
00:07:57,760 --> 00:08:03,310
So always after restoring, refresh the database and check if the tables are created or not.
90
91
00:08:04,210 --> 00:08:11,980
Lastly, if nothing else works, the last option, which always works is creating the tables individually
91
92
00:08:12,280 --> 00:08:15,180
and loading the data from CSV files.
92
93
00:08:16,240 --> 00:08:18,700
So we have provided the CSV files also.
93
94
00:08:19,120 --> 00:08:25,150
And in the next video, I'll show you how to create those three individual tables and restore the CSV
94
95
00:08:25,150 --> 00:08:25,600
files.
9985
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.