January 8, 2010

MySQL and Snow Leopard (Mac OS X, 10.6.x)

After upgrading to Snow Leopard, the symlink was lost in /usr/local

cd /usr/local
sudo ln -s mysql-5.1.37-osx10.5-x86_64/ mysql

Simply run that in the Terminal, and you should be all set.

August 12, 2009

Filter Small Files from the ‘du’ Command with Grep

Ever wanted to filter out the files that were less than 1GB with the simple ‘du’ (disk usage) command? Simple. Add the -h flag and a little grep magic, and you’re all set:

du -h | grep '[0-9]G'

June 18, 2009

MySQL Table Is Marked As Crashed and Should Be Repaired

I was greeted by the following error this evening from within my SugarCRM instance:

MySQL error 1194: Table 'contacts' is marked as crashed and should be repaired

So this is what I did to fix it:

[root@crm ~]# mysql -p
Enter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.

mysql> use sugarcrm
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> CHECK TABLE contacts;
+-------------------+-------+----------+-----------------------------+
| Table             | Op    | Msg_type | Msg_text                    |
+-------------------+-------+----------+-----------------------------+
| sugarcrm.contacts | check | error    | Found wrong record at 73544 |
| sugarcrm.contacts | check | error    | Corrupt                     |
+-------------------+-------+----------+-----------------------------+
2 rows in set (0.18 sec)

mysql> REPAIR TABLE contacts;
+-------------------+--------+----------+-----------------------------------------------------+
| Table             | Op     | Msg_type | Msg_text                                            |
+-------------------+--------+----------+-----------------------------------------------------+
| sugarcrm.contacts | repair | info     | Key 1 - Found wrong stored record at 73544          |
| sugarcrm.contacts | repair | info     | Found block with too small length at 78096; Skipped |
| sugarcrm.contacts | repair | warning  | Number of rows changed from 892 to 877              |
| sugarcrm.contacts | repair | status   | OK                                                  |
+-------------------+--------+----------+-----------------------------------------------------+
4 rows in set (0.26 sec)

April 22, 2009

Using Plesk’s Backup Feature

In it’s simplest form, this will back up your entire plesk installation:

/usr/local/psa/bin/pleskbackup all /backup/pleskbackup

You have many other options, however, such as splitting the backup into little files, and FTPing them directly to a remote server.

Here are the helpfiles:

Usage: pleskbackup [<global-options>] <command> [<FTP options>] [<local-options>] <arguments>
                    <output-file>

Global options:
  -v|--verbose
                 Show more information about backup process. Multiple -v
                 options increase verbosity.

  -c|--configuration
                 Backup only configuration of objects, not the content.

  -s|--split[=<size>]
                 Split the generated backups to the parts. Parts are numbered
                 by appending .NNN suffixes, starting with .001.

                 Size may be specified in kilobytes (<nn>K), megabytes (<nn>M)
                 and gigabytes (<nn>G).

                 '-s' option without argument selects default split size:
                 2 gigabytes.

  -z|--no-gzip   Do not compress backup file

Commands:
  all            Backs up whole Plesk.

  clients        Backs up selected clients. Clients are read from command line,
                 space-separated. If no clients provided, backs up all clients
                 on the host.

  domains        Backs up selected domains. Domains are read from command line,
                 space-separated. If no domains provided, backs up all domains
                 on the host.

                 Options --exclude and --exclude-file may be specified for
                 excluding some clients/domains.

  help           Shows this help page

FTP options:
 --ftp-login=<ftp_login>
                 Specify the FTP login
 --ftp-password=<ftp_password>
		Specify the FTP password (used with '--ftp-login')

Local options:
  -f|--from-file=<file>
                 Read list of domains/clients from file, not from command line.
                 File should contain list of domains/clients one per line.

  --exclude=<obj1>,<obj2>,...
                 Excludes listed domains/clients from backup list.

  --exclude-file=<file>
                 Excludes domains/clients listed in file from backup list.
                 File should contain list of domains/clients one per line.

  --skip-logs    Do not save log files in the backup file

Output file:
  /fullpath/filename - regular file,

  -                  - use stdout for output,

  ftp://[<login>[:<password>]@]<server>/<filepath> - storing the backup to ftp server.
  FTP_PASSWORD environment variable can be used for setting password.
  FTP option '--ftp-login' can be used for setting login.
  FTP option '--ftp-password' (with '--ftp-login') can be used for setting password.

Plesk Backup Error: ‘ERROR Unable to open /opt/psa/var/apspkgarc/archive-index.xml’

I was getting the following error when trying to use Plesk’s backup function:

ERROR Unable to open /opt/psa/var/apspkgarc/archive-index.xml

The solution is to visit the “Application Vault” under the “Server” tab of your Plesk interface.  The file gets auto-generated at that point.

For more information on how to use Plesk’s backup feature, read this post