Hi,
Not sure where best to post this, as the scripting section seemed aimed more at the pre-included scripts and DA API - so here will do. Mods, feel free to move it as needed.
Recently had need to migrate users between servers using the old AWStats plugin setup to one using the DA AWStats method. This means moving all the data from /etc/awstats/ to the relevant folder in /home/$user/domains/$domain/awstats/.data/ and updating the configuration file.
I'm sure it could be tidier, etc - but it does the trick nicely. Should be run on the new server once the accounts have been migrated (backup/restore on new box) and will fetch the awstats files from the old server. Make sure to put an SSH key in place first or you're going to get a lot of password requests.
Feel free to make use of it - but at your own risk.
Not sure where best to post this, as the scripting section seemed aimed more at the pre-included scripts and DA API - so here will do. Mods, feel free to move it as needed.
Recently had need to migrate users between servers using the old AWStats plugin setup to one using the DA AWStats method. This means moving all the data from /etc/awstats/ to the relevant folder in /home/$user/domains/$domain/awstats/.data/ and updating the configuration file.
I'm sure it could be tidier, etc - but it does the trick nicely. Should be run on the new server once the accounts have been migrated (backup/restore on new box) and will fetch the awstats files from the old server. Make sure to put an SSH key in place first or you're going to get a lot of password requests.
Code:
#!/bin/bash
#Script for copying awstats data into updated folder structure.
#Make sure you have an SSH key in place or it's gonna be painful.
#
#Set $origserver below with hostname/ip of server containing existing awstats data
#
origserver=123.123.123.123
#
for i in `find /home -maxdepth 3 -type d -name domains | xargs ls -l | grep -v admin | awk '{ print $9 }' | tail -n +2`;
do
for j in `find /home -maxdepth 3 -type d -wholename *domains/*$i*`;
do
scp root@$origserver:/etc/awstats/*$i* $j/awstats/.data/;
k=`echo "$j" | cut -d/ -f3`;
sed -e "s|DirData=\"/etc/awstats\"|DirData=\"/home/$k/domains/$i/awstats/.data\"|" -i $j/awstats/.data/*.conf
done
done
Feel free to make use of it - but at your own risk.