We’ll continue using the _postgres user for now. This is where these backups will end up getting stored. We’re going to create a folder on the root of the volume called db_backups first: Next, let’s look at dumping the databases. Or to make it a bit simpler if you don’t have a lot of data in there yet:ĭevice_management=# select * from "public"."tasks" Īfter seeing the output, you’ll probably be a little appreciative of Apple’s formatting. These are stored in the tasks table (aptly named), so we’re going to run the following SQL query (note a space followed by a semi-colon is required at the end of this thing):ĭevice_management=# select * from "public"."tasks" limit 1000 offset 0 To put some SQL commands into action, we’re going to look at the tasks that have been performed by Profile Manager. Run the help command to see a list of SQL commands that can be run and ? for a list of psql options. To see all of the tables, use d:Īs you can tell, there are a bunch of them. Now that there’s a valid user, let’s see what else we can do.
MAC COMMAND LINE POSTGRES URL PASSWORD
To then create a new user called krypted with a password of daneel we’ll use the create option, defining a user as the type of object to create, followed by the user name and then with password followed by the password (single quoted) and then createuser as follows:ĭevice_management=# create user krypted with password 'daneel' create user To string this together, for accessing the device_management database as _postgres: To define a database, use the -d option (device_management providing access to Profile Manager data, caldav to iCal Server data roundcubemail to WebMail data and collar to Wiki data). Any time you want to invoke psql with a different user than the user you are currently logged in as, use the -U option.
To do so, we will have to use the _postgres user to invoke psql. Because a lot of commands require passwords and we might not always want to provide write access to the databases, we’re going to create a new SuperUser, called krypted with a password of daneel. In Lion Server, the only user that can access the Postgres databases is _postgres, installed by default with Lion Server.
However, as it’s usually more verbose with errors, I like to use psql to do this. For example, PostgreSQL comes with a command /user/bin/createuser. Many of the other commands simply provide automated options to psql, and over time I’ve started using psql for most everything. Postgres has a number of commands that can be used to interact with databases. As such, it’s now important to be able to use PostgreSQL the way we once used SQLite3, when trying to augment the data that these databases contains, as there currently aren’t a lot of options for editing this data (aside from manually of course). One of these is the move from SQLite3 to PostgreSQL for many of the back-end databases, including Wiki and Podcast Producer (collab), Webmail (roundcubemail), iCal Server and Address Book Server (caldav) and as the back-end to the newest service in Lion Server, Profile Manager (device_management).
MAC COMMAND LINE POSTGRES URL MAC OS X
Mac OS X Server 10.7, Lion Server, comes with a few substantial back-end changes.