Bulk Change Web Hosting & Mail Settings Quickly and Easily with Plesk CLI

2. List of business objects to configure

The list of business objects (such as domain names) to be processed in the loop can be manually written line-by-line in a text file or generated from a Plesk database via Plesk CLI commands or database queries. However, lists can also be exported from other data sources, such as spreadsheet applications.

tedious manual way

For example, you can use a text editor to write domain names or email addresses line by line into a text file. Use a Windows text editor, a spreadsheet with lines exported to a text file and uploaded to the server, a Linux “vi” or “nano” editor, or any other method you can think of. Make sure each entry stands alone on a single line in the text file. yes:

first-domain.tld
second-domain.tld
third-domain.tld
.
.
.
nth-domain.tld

It takes a lot of effort to write this by hand. So in most cases the list is automatically generated, for example via a database query or Plesk CLI command.

The Simple Plesk Command Way

You may also need a list of all websites. You can use “plesk bin site –list” for this and save the result to a file via output redirection “>”.

# plesk bin site --list > websites.txt

Or maybe you want to make bulk changes to your mailbox configuration. To do this, you can run the command “plesk bin mail -l” (to show all mail addresses) and filter the result with “grep ‘Mail name'” to get only the mailboxes. Then, since we only need the third column (because it’s the mailbox name), we add “awk ‘{print $3}'” and finally save the result to a file with output redirection “>”.

# plesk bin mail -l | grep "Mail name"| awk '{print $3}' > mailboxes.txt

Work with database queries like a pro

Some tasks may be more complex. You may only want a list of mailboxes matching certain criteria. To do this, you can generate a list of items from a database query and filter by criteria. For example, instead of using the “plesk bin mail” command, you can generate a list of all mailboxes as follows:

# plesk db -Ne "SELECT CONCAT_WS('@', a.mail_name, b.name) FROM psa.mail AS a 
INNER JOIN psa.domains as b ON b.id = a.dom_id WHERE a.postbox LIKE 'true';"
> mailboxes.txt

You can insert arbitrary conditions here. For example, only all mailboxes whose names start with “x”:

# plesk db -Ne "SELECT CONCAT_WS('@', a.mail_name, b.name) FROM psa.mail AS a 
INNER JOIN psa.domains as b ON b.id = a.dom_id WHERE a.postbox LIKE 'true'
AND a.mail_name LIKE 'x%';" > mailboxes_starting_with_a.txt

Your imagination has no limits. Plesk allows you to do this and much more because you always have full access to all your data managed by Plesk. If you want to use database queries, the “psa” database is the place to find all Plesk business objects and configurations.

Source

2. List of business objects to configure

The list of business objects (such as domain names) to be processed in the loop can be manually written line-by-line in a text file or generated from a Plesk database via Plesk CLI commands or database queries. However, lists can also be exported from other data sources, such as spreadsheet applications.

tedious manual way

For example, you can use a text editor to write domain names or email addresses line by line into a text file. Use a Windows text editor, a spreadsheet with lines exported to a text file and uploaded to the server, a Linux “vi” or “nano” editor, or any other method you can think of. Make sure each entry stands alone on a single line in the text file. yes:

first-domain.tld
second-domain.tld
third-domain.tld
.
.
.
nth-domain.tld

It takes a lot of effort to write this by hand. So in most cases the list is automatically generated, for example via a database query or Plesk CLI command.

The Simple Plesk Command Way

You may also need a list of all websites. You can use “plesk bin site –list” for this and save the result to a file via output redirection “>”.

# plesk bin site --list > websites.txt

Or maybe you want to make bulk changes to your mailbox configuration. To do this, you can run the command “plesk bin mail -l” (to show all mail addresses) and filter the result with “grep ‘Mail name'” to get only the mailboxes. Then, since we only need the third column (because it’s the mailbox name), we add “awk ‘{print $3}'” and finally save the result to a file with output redirection “>”.

# plesk bin mail -l | grep "Mail name"| awk '{print $3}' > mailboxes.txt

Work with database queries like a pro

Some tasks may be more complex. You may only want a list of mailboxes matching certain criteria. To do this, you can generate a list of items from a database query and filter by criteria. For example, instead of using the “plesk bin mail” command, you can generate a list of all mailboxes as follows:

# plesk db -Ne "SELECT CONCAT_WS('@', a.mail_name, b.name) FROM psa.mail AS a 
INNER JOIN psa.domains as b ON b.id = a.dom_id WHERE a.postbox LIKE 'true';"
> mailboxes.txt

You can insert arbitrary conditions here. For example, only all mailboxes whose names start with “x”:

# plesk db -Ne "SELECT CONCAT_WS('@', a.mail_name, b.name) FROM psa.mail AS a 
INNER JOIN psa.domains as b ON b.id = a.dom_id WHERE a.postbox LIKE 'true'
AND a.mail_name LIKE 'x%';" > mailboxes_starting_with_a.txt

Your imagination has no limits. Plesk allows you to do this and much more because you always have full access to all your data managed by Plesk. If you want to use database queries, the “psa” database is the place to find all Plesk business objects and configurations.

Source

More from author

Related posts

Latest posts

Dynamic List vs. Active List: A Comprehensive Comparison – Unveiling the Ultimate Winner!

Problem: Difficulty finding necessary controls in the domain overviewwithin the domain outline A variety of essential tools are waiting for you., streamlines the development...

5 Tips for Picking the Best Load Balancer

In today's rapidly changing and highly demanding digital environment, consumers expect web applications to be fast and reliable. According to Google Search Advocate...

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!