I found this script but couldn't manage to adjust it for parts. Here's what I got so far:
\documentclass{book}
\usepackage{background}
\usetikzlibrary{calc}
\usepackage{ifthen}
\usepackage{lipsum}
\pagestyle{plain}
% background common settings
\SetBgScale{1}
\SetBgAngle{0}
\SetBgOpacity{1}
\SetBgContents{}
% auxiliary counter
\newcounter{partshift}
\addtocounter{partshift}{-1}
\definecolor{mp}{RGB}{240,240,240}
\let\Oldpart\part
\newcommand{\parttitle}{}
\renewcommand{\part}[1]{\Oldpart{#1}\pf\renewcommand{\parttitle}{#1}}
% the main command; the mandatory argument sets the color of the vertical box
\makeatletter
\newcommand\pf{%
\AddEverypageHook{%
\ifthenelse{\isodd{\thepage}}
{\SetBgContents{%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=mp,inner sep=0pt,rectangle,text width=2cm,
text height=4cm,align=center,anchor=north east]
at ($ (current page.north east) + (-0cm,-2*\thepartshift cm) $)
{\rotatebox{90}{\hspace*{.3cm}\parbox[c][1.5cm][t]{3.4cm}{%
\raggedright\textcolor{black}{\parttitle}}}};
\end{tikzpicture}}%
}
{\SetBgContents{%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=mp,inner sep=0pt,rectangle,text width=2cm,
text height=4cm,align=center,anchor=north west]
at ($ (current page.north west) + (-0cm,-2*\thepartshift cm) $)
{\rotatebox{90}{\hspace*{.3cm}\parbox[c][1.5cm][t]{3.4cm}{%
\raggedright\textcolor{black}{\parttitle}}}};
\end{tikzpicture}}
}
\bg@material}%
\stepcounter{partshift}
}
\makeatother
\begin{document}
\part{A}
\chapter{a1}
\lipsum[1-7]
\part{B}
\chapter{b1}
\lipsum[1-7]
\part{C}
\chapter{c1}
\lipsum[1-7]
\end{document}
