Trello – backup to your linux machine

Just in case, you are looking for backing up your trello account boards, you can use the following bash script to do so:

 

#!/bin/bash -
#===============================================================================
#
#          FILE: backup-trello.sh
#
#         USAGE: ./backup-trello.sh
#
#   DESCRIPTION:
#
#       OPTIONS: ---
#  REQUIREMENTS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Amit Agarwal (aka)
#  ORGANIZATION: Mobileum
# Last modified: Thu Dec 22, 2016  01:14PM
#       CREATED: 08/12/2016 09:41:08 AM IST
#      REVISION: $Revision: 1.0 $$
#===============================================================================

# Your backup directory
BDIR=/backup

# Your trello api token and key goes here 🙂
token=<>
key=<>


# IDs of the boards go here. This is easy to get, just go to your 
# board and check the last part of URL
BOARDS=( a b )


URL="https://trello.com/b/"
POST='&actions=all&actions_limit=1000&cards=all&lists=all&members=all&member_fields=all&checklists=all&fields=all'

for i in ${BOARDS[*]}
do
    /usr/bin/curl -H 'Accept-Encoding:gzip, deflate, br' -H 'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' "$URL$i.json?&key=$key&token=$token$POST" > "$BDIR/$i.json.gz"
    # gzip -f "$BDIR/$i.json"
done

 

You can add this script in cron, if you wish to do so 🙂

Oh, and BTW the script gets the details in zipped format so output is created as <id of board>.json.gz.

Get your local IP address like pro

In shell scripts if you need to get you local IP address corresponding to your hostname then you can use this command

hostname -i

email with templates (with variables) from the command line with sendmail or any other MTA.

I was trying to get templates to work on evolution and found that although templates are there in evolution mail client, its not that efficient to use. What I thus wanted was to have something that could allow me to send mails to (and cc and bcc) to specified people with predefined template, only some values changed, like changelog and so on. So I wrote a set of files and below files to achieve the same. Hope it helps you too 🙂

First we will have a file called \”fields\” containing all the variable that we intend to use:

template=\”template.changelog\”
product=\”ABC\”
customer=\”personal\”
tag=\”2.0.98-12\”
subject=\”Changelog\”
issue=\”Bug-119876\”
to=\”Amit\”
cc=\”Amit Agarwal\”
attachment=\”/tmp/changelog\”

Ok, so here we are defning the to field, cc field and the other fields along with the name of the file to attach. Next we need the template to use. Create a file called \”template.changelog\” as defined in the above file:

Hi,

Please find the changelog for $tag for $product-$customer. Issue addressed : $issue .

Thanks

-aka

Next we have a shell script called \”mail.sh\” to actually send the mail. Here is the script:

source ./fields
rm -rf .temp .temp1
touch .temp
sed \”s/\\$product/$product/g\” $template > .temp1
sed \”s/\\$customer/$customer/g\” .temp1 > .temp

sed \”s/\\$issue/$issue/g\” .temp1 > .temp1
sed \”s/\\$tag/$tag/g\” .temp1 > .temp

rm -f .temp1
sendEmail -xu user  -xp pass  -s server  -f agarwal -t \”$to\” -cc \”$cc\” -u \”[$product-$customer]:$subject for $issue\” -o message-file=.temp -a $attachment
echo \”Mail sent with \\nSubject $subject \\nto $to \\nand copied to $cc and \\nattached $attachment\”

In the shell script I am using sendEmail, but you can use any MTA that you want. 🙂

Well, I think you get the idea, so you can modify the script to include the necessary checks and modify according to your needs.

[[danscartoon]]