Skip to content

Grant Klaaysen

My feedback

1 result found

  1. 14 votes

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)

    We’ll send you updates on this idea

    How important is this to you?

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    An error occurred while saving the comment
    Grant Klaaysen commented  · 

    Am having issues attached the script file even when zipped.
    Please see below code if you want to make your own script.

    -------------------------------------------------------------------------------

    #!/bin/bash
    # ---

    # Script to recreate Plesk ***** DNS zones on all nameservers using rsync commands - delzone, addzone and refreshzone
    # Copyright (C) 2020 GPK Group Pty Ltd (www.gpkgroup.com.au)
    # Permission to copy and modify is granted under the BSD license
    # Last revised 28/04/2020
    #
    # Usage: plesk_recreate_slave_zones.sh domain.com.au

    # Get the specified domain name
    DOMAIN_NAME=$1

    if [ -z $DOMAIN_NAME ]
    then
    echo "Error: no domain was specified"
    exit 1
    fi

    DIRECTORY=/usr/local/psa/var/modules/*****-dns-manager

    # Find all *.conf files
    files=($DIRECTORY/*.conf)

    for file in ${files[@]}
    do
    failed=0
    FILE_CONTENT="$(cat $file)"

    # Extract server IP from file
    SERVER_IP=$(grep -A1 "For example:$" $file | grep -oP '(?<=\-b )([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})')

    if [ $? -eq 1 ]
    then
    echo "Error: Plesk server IP was not found in $file"
    failed=1
    fi

    NAMESERVER_IP=$(grep -A1 "For example:$" $file | grep -oP '(?<=\-s )([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})')

    if [ $? -eq 1 ]
    then
    echo "Error: ***** nameserver IP was not found in $file"
    failed=1
    fi

    if [ $failed -eq 0 ]
    then
    echo "Recreating DNS zone $DOMAIN_NAME on ***** nameserver $NAMESERVER_IP for Plesk server $SERVER_IP"

    # Delete
    /usr/sbin/rndc -b $SERVER_IP -s $NAMESERVER_IP -p "953" -y "rndc-key" -c $file delzone -clean $DOMAIN_NAME
    sleep 5

    # Create
    /usr/sbin/rndc -b $SERVER_IP -s $NAMESERVER_IP -p "953" -y "rndc-key" -c $file addzone $DOMAIN_NAME "{ type *****; file \"$DOMAIN_NAME\"; masters { $SERVER_IP; }; };"
    sleep 5

    # Refresh
    /usr/sbin/rndc -b $SERVER_IP -s $NAMESERVER_IP -p "953" -y "rndc-key" -c $file refresh $DOMAIN_NAME
    fi
    done

    An error occurred while saving the comment
    Grant Klaaysen commented  · 

    Script File attached hopefully this time.

    An error occurred while saving the comment
    Grant Klaaysen commented  · 

    Hi guys,

    Further to this topic we have created a script that will automate the post migration process with updating the name servers to get the dns data from the new master server.

    The script will lookup the Plesk Slave DNS settings to work out how many slave dns servers you have and where they are.

    Syntax is from an SSH session:
    plesk_recreate_slave_zones.sh example.com

    Of course please review the script, we give no warranties but I have been using it and it has been working well.

    Plesk Team, can you please review and incorporate this script onto your code?
    Or give us an option to run a script as a post migration feature.

    This would just make the Plesk to Plesk migration tool completed and fully automated when using the Plesk Slave DNS Extension.

    Thanks Tully who put this script together for me. :)

    Regards,
    Grant

    Grant Klaaysen supported this idea  · 
    An error occurred while saving the comment
    Grant Klaaysen commented  · 

    Perfect, this is exactly what I am looking for and agree it could be so simple to implement.

    Post migration of the domain the migration tool just needs to do the rndc delzone and rndc addzone as you have highlighted.

    That small change would make a massive improvement to the migration work and make it super simple to do.

    Please add this feature or let us know if we could add some code to the post migration settings to execute the rndc commands.

Feedback and Knowledge Base