Created
May 7, 2012 17:49
-
-
Save xoebus/2629277 to your computer and use it in GitHub Desktop.
Tweet Backup Script - Based on: http://blog.jphpsf.com/2012/05/07/backing-up-your-twitter-account-with-t/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# A twitter backup script. | |
function line_count { | |
echo `cat $1 | wc -l | sed -e 's/^[ \t]*//'` | |
} | |
# Setup | |
mkdir -p `pwd`/archives | |
DAY=`date +'%Y-%m-%d'` | |
USERNAME='@xoebus' | |
echo "Backing up timeline..." | |
t timeline $USERNAME --csv --number 3000 > tweets-$DAY.csv | |
echo "Backing up retweets..." | |
t retweets --csv --number 3000 > retweets-$DAY.csv | |
echo "Backing up favourites..." | |
t favorites --csv --number 3000 > favorites-$DAY.csv | |
echo "Backing up received DMs..." | |
t direct_messages --csv --number 3000 > dm_received-$DAY.csv | |
echo "Backing up sent DMs..." | |
t direct_messages_sent --csv --number 3000 > dm_sent-$DAY.csv | |
echo "Backing up followings..." | |
t followings --csv > followings-$DAY.csv | |
echo "\nBacked up the following:" | |
echo " -" $(line_count tweets-$DAY.csv) "tweets" | |
echo " -" $(line_count retweets-$DAY.csv) "retweets" | |
echo " -" $(line_count favorites-$DAY.csv) "favorites" | |
echo " -" $(line_count dm_received-$DAY.csv) "DM received" | |
echo " -" $(line_count dm_sent-$DAY.csv) "DM sent" | |
echo " -" $(line_count followings-$DAY.csv) "followings" | |
echo "\nArchiving..." | |
tar -czf archive-$DAY.tar.gz *.csv | |
mv archive-$DAY.tar.gz archives | |
echo "Cleaning up..." | |
rm *.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment