Change system user for a domain in Plesk - plesk

I have a server with Plesk installed, running a couple of webs.
One of them, the-subdomain.com, started as a subdomain of another one, the-domain.com. They were created using the same system user and it was hosted in a subdirectory of httpdocs (httpdocs/the-subdomain).
Now I want to change the-subdomain.com to its own system account, but Plesk does not have the option to do it.
Is there an easy way to do this?

This is how I did:
Firs, I created another subscription (the-subdomain2.com), as Oleg said
Then, I copied all data to new subscription
After that, I tested all was working fine touching my local hosts file
Then, I deleted the old subscription
The last step was to rename the-subdomain2.com to the-subdomain.com
Unrelated to this, while playing with susbscriptions, I created a system user which then I needed to delete. Plesk hasn't the option to delete the user, so I deleted the account on the machine (userdel -r THE_USER_TO_DELETE) and then on the Plesk database (use psa; delete from sys_users where login='THE_USER_TO_DELETE';)

Related

How do i restart PostgreSQL service after putting back the original Data folder?

I'm writing some batch scripts for doing incremental backups of a PostgreSQL cluster on a Windows Server.
I copied the Data folder to a different folder, ran my backup scripts, stopped the service, deleted the Data folder, and tried recovering the database from the WAL files and such.
This didn't work, because i copied the wrong log files, and i couldn't get the service started again, so i tried copying back in the original Data folder, but i still can't start the service.
The first script i ran called:
pg_basebackup -Fp -D %BACKUPDIR%\full_%CURRENTDATE%
This was the only line which actually ended up interacting with the data, but not the original Data folder, which i copied beforehand.
When trying to start the service again i get the following error message:
The postgresql-x64-10 - PostgreSQL Server 10 service on Local Computer started and then stopped.
Some services stop automatically if they are not in use by other services or programs.
I have gotten this before, when making a typo in the conf file, so i'm guessing that's just the standard error message for when something is missing.
Found out that i had to redo the folder permissions.
This is done the following way:
5. Change permissions for the new data directory
For the new data-dictionary folder: Right-click on it and click Properties. Under the Security Tab click “Edit...” and then “Add...”. Type “Network Service” and then click “Check Names”, make sure it has Modify and Full Control permissions and then click OK. Equally important PostgreSQL needs to be able to “see” the data-directory (see my ServerFault.StackEx question), i.e. it needs to have read access to the parent directories above it. So Right-click on the pg_db folder and under the Security Permissions add Network Services again, but this time it only needs Read & Execute as well as List folder contents permissions.
The full post is a nice checklist to go through, for anyone else facing similar issues:
https://radumas.info/blog/tutorial/2016/08/08/Migrating-PostgreSQL-Data-Directory-Windows.html

Partial Recovery from AD Recyle Bin

I have a small Windows domain which became "a little bit" corrupted over time. Now I want to cleanup using an older VM of a DC (WinSrvr 2008R2) with a healthy AD structure. For this I removed the existing DCs physically from the network without downgrading them to normal servers. Then I started up the virtual DC and created some non-DCs successfully. Existing non-virtual workstations, which had been added to the domain after the reanimated server was sent to sleep, allow successful login. I assume that this is possible because the domain users are allowed to login from anywhere. However, these machines cannot access the new VMs besides the reanimated server because they are not known to the domain which is obvious. Also some services run under some domain identities do not start up because these identities are not known to the reanimated server.
Now I read that since WinSrvr 2008R2 it is possible to restore deleted objects from the AD recyle bin. So my hope is it will be possible to restore the objects (users, groups, computers, an possibly some others) from the AD recycle bin. For this, the following procedure appears feasible to me:
Start one of the isolated DCs leaving it isolated
Remove the objects of interest from AD
Export the recycle bin to a file
Import the recycle bin from this file to the reanimated DC
Recover objects from the recycle bin on the reanimated DC
While all this looks consistent to me, I have no idea how to perform steps 3 and 4. Do there exist any experiences of how to do that? I would be really glad.
Correction:
Login from later added computers is not possible anymore. Probably cached credentials expired.

Dotnet Nuke Installation

I have been able to install DNN at my local machine, but after I run the default website the code asked me about the Database configuration in first step. When I proceed to the next step the progress is not exceeding from 15%. I have restarted the website many times but the progress stucks at this point and is not proceeding further. Is there anything which I need to be done before this step? Here is the second step in which I need help-
Please check your database name, username and password as well as your instance name.
I'm assuming you've created your database first, and then given the user you are using permissions to that database.
It's stopping on the install Database Schema, so it seems like your the Database user you are using may not have enough permissions.
Put that user in the DBO role and also, (TEMPORARILY) give them sysadmin, serveradmin, and secruityadmin rights. I do this, and then take it away AFTER the install.
You can check out the installation guide if you have not yet: http://www.dnnsoftware.com/wiki/Page/Install_DotNetNuke
And, the DNN videos are very good: http://www.dnnsoftware.com/videos

Can not copy SQL Server files, Access is denied

I need to copy my SQL Server DBs to a folder. The files are attached to SQL Server, which I have detached using my code. When I try to copy these files using
My.Computer.FileSystem.CopyFile(filePathToCopyFrom1, targetFilePath1)
It returns error:
"Access to the folder D:\MyDbs is denied"
When I manually coped these files, it asked "You need Administror permission to copy these files" I clicked continue and it worked but how to fix this using my vb.net code?
I have given Full Control to administrator from Windows but still it did not work.
Thanks
Seems that the detaching process went well. You can copy through windows explorer, but not from you application. The key difference here is that the files are protected to be accessed by the administrator user only.
Then, you need to run your application using an administrator windows account so that the application inherits the permissions of the user to be able to perform this operation.
Remember, if you are using Windows Vista+ (which I assume you do) the root folder is almost off limits. You can run the App as Administrator, or copy it to a folder in the root. The other point is that where you copy from. If the DB is currently in Program files, it is very possible that you will get this problem as well, and then you will have to run the application as Administrator.
Right click on the application, and select Run as Administrator, or select properties and in Compatibility check the box that the program should be running as Administrator. If you use the latter, then a box will pop up every time you run it, unless you change the User Account Control settings.

Recover postgreSQL databases from raw physical files

I have the following problem and I need to know if there´s a way to fix it.
I have a client who was cheap enough to decline buying a backup plan for his postgreSQL databases on the main system that runs his company and as I thought it would happen some day, some OS files crashed during a blackout and the OS needs to be reinstalled.
This client didn't have any backups of the databases but I managed to save the PostgreSQL main directory. I read that the databases are stored somehow inside the data directory of the postgres main folder.
My question is: Is there any way to recover the databases from the data folder only? I am working in a windows environment (XP service pack 2) with PostgreSQL 8.2 and I need to reinstall PostgreSQL in a new server. I would need to recreate the databases in the new environment and somehow attach the old files to the new database instances. I know that's possible in SQL Server because of the way that engine stores the databases but I have no clue in postgres.
Any ideas? They would be much appreciated.
If you have the whole data folder, you have everything you need (as long as architecture is the same). Just try restoring it on another machine before wiping this one out, in case you didn't copy something.
Just save the data directory to disk. When launching Postgres, set the parameter telling it where the data directory is (see: wiki.postgresql.org). Or remove original data directory of the fresh installation and place the copy in its place.
This is possible, you just need to copy the "data" folder (inside the Postgres installation folder) from the old computer to the new one, but there are a few things to keep in mind.
First, before you copy the files, you must stop the Postgres server service. So, Control Panel->Administrative tools->Services, find Postgres service and stop it. When you're done copying the files and setting permissions, start it again.
Second, you need to set the permissions for the data files. Because postgres server actually runs on another user account, it will not be able to access the files if you just copy them into the data folder, because it will not have permissions to do so. So you need to change the ownership of the files to the "postgres" user. I had to use subinacl for this, install it first, and then use it from command prompt like this (first navigate to folder where you installed it):
subinacl /subdirectories "C:\Program Files\PostgreSQL\8.2\data\*" /setowner=postgres
(Changing ownership should also be possible to do from the explorer: first you must disable "Use simple file sharing" in Folder options, then a "Security" tab will appear in the folder Properties dialog, and there are options there to set permissions and change ownership, but I wasn't able to do it that way.)
Now, if the server service can't start after you start it manually again, you can usually see the reason in the Event viewer (Administrative tools->Event viewer). Postgres will throw an error event, and inspecting it will give you a clue about what the problem is (sometimes it will complain about a postmaster.pid file, just remove it, etc.).
The question is very old, but I want to share an effective method that I found.
If you have not got a backup with "pg_dump" and your old data is folder, try the following steps.
In the Postgres database, add records to the "pg_database" table. With a manager program or "insert into".
Make the necessary check and change the following insert query and run it.
The query will return an OID after it has worked. Create a folder with the name of this number. Once you have copied your old data into this folder, the use is now ready.
/*
------------------------------------------
*** Recover From Folder ***
------------------------------------------
Check this table on your own system.
Change the differences below.
*/
INSERT INTO
pg_catalog.pg_database(
datname, datdba, encoding, datcollate, datctype, datistemplate, datallowconn,
datconnlimit, datlastsysoid, datfrozenxid, datminmxid, dattablespace, datacl)
VALUES(
-- Write Your collation
'NewDBname', 10, 6, 'Turkish_Turkey.1254', 'Turkish_Turkey.1254',
False, True, -1, 12400, '536', '1', 1663, Null);
/*
Create a folder in the Data directory under the name below New OID.
All old backup files in the directory "data\base\Old OID" are the directory with the new OID number
Copy. The database is now ready for use.
*/
select oid from pg_database a where a.datname = 'NewDBname';
As shown by move database to another hard drive. All we need to do is to modify the registry table and file permissions. By modifying registry table(shown in image 1), postgresql server know the new location of data.
modify registry
If you have issues with permissions or with stuff like icacls during installation to old data folder then try my solution from sister website.
https://superuser.com/a/1611934/1254226
I do so but the most tricky part was to change the owner permission:
go to services from administative tools
find postgres service and double click on it
at log on tab change to local system
then restart

Resources