Page 1 of 1

restore multiple accounts

Posted: Mon Jul 20, 2015 12:14 am
by elicast
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

Re: restore multiple accounts

Posted: Mon Jul 20, 2015 11:13 am
by tjebbeke
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

Posted: Tue Jul 21, 2015 12:37 am
by elicast
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?

Re: restore multiple accounts

Posted: Wed Oct 23, 2019 9:28 am
by skurudo
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