restore multiple accounts
restore multiple accounts
Anyone know how I can start a function to restore multiple account.
I needed restaruar all accounts and had to edit user name at the command one by one
v-restore-user user user.2015-07-19.tar
v-restore-user user2 user2.2015-07-19.tar
and lost a lot of time, imagine 200 sites to edit this line one by one
I needed restaruar all accounts and had to edit user name at the command one by one
v-restore-user user user.2015-07-19.tar
v-restore-user user2 user2.2015-07-19.tar
and lost a lot of time, imagine 200 sites to edit this line one by one
-
- Collaborator
- Posts: 783
- Joined: Mon May 11, 2015 8:43 am
- Contact:
- Os: CentOS 6x
- Web: apache + nginx
Re: restore multiple accounts
You can create a bash script something like this:
Code: Select all
#!/bin/bash
DATE=$(date +%F)
FILES=$(find /home/backup -name "*$DATE.tar")
for f in $FILES
do
FILE=$(basename $f)
USER=$(echo $FILE | cut -f1 -d".")
echo "v-restore-user $USER $FILE"
#v-restore-user $USER $FILE
done
exit 0
Re: restore multiple accounts
perfect code, thank you
I'm a difficulty, it just fucniona put all the code in manually terminal
I created a file called restore-all and put in /usr/local/vesta/bin
but give the command sudo /usr/local/vesta/bin/restore-all
says does not exist, some adjustment I can do?
I'm a difficulty, it just fucniona put all the code in manually terminal
I created a file called restore-all and put in /usr/local/vesta/bin
but give the command sudo /usr/local/vesta/bin/restore-all
says does not exist, some adjustment I can do?
Re: restore multiple accounts
A little change in script with date format:
Code: Select all
#!/bin/bash
DATE=$(date +%F %T)
FILES=$(find /backup/ -name "*$DATE.tar")
for f in $FILES
do
FILE=$(basename $f)
USER=$(echo $FILE | cut -f1 -d".")
echo "v-restore-user $USER $FILE"
v-restore-user $USER $FILE
done
exit 0